달력

11

« 2019/11 »

  •  
  •  
  •  
  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
2010.04.08 14:34

VisualBasic ODBC를 이용한 DB접속 Language/VB2010.04.08 14:34

기본적으로 project-references-MicroSoft ActiveX Data Objects 2.8 Library가 체크인
되어 있어야한다.

- MsSql 접속


  '선언부

  Dim RS_MS As ADODB.Recordset
  Dim ado_MS As ADODB.Connection

  '사용시
  Dim strconn As String

  strconn = "Provider=MSDASQL;dsn=dsnname;Database=databasename;UID=username;PWD=password;"

  Set ado_MS = New ADODB.Connection
  ado_MS.CursorLocation = adUseClient
  ado_MS.Open strconn


- Oracle 접속

  '선언부
  Dim ado_Ora As ADODB.Connection
  Dim RS_Ora As ADODB.Recordset

  '사용시
  Dim strconn As String

  strconn = "Provider=MSDAORA.1;Persist Security Info=False;User ID=userid;Password=password;Data Source=datasourcename"

  Set ado_Ora = New ADODB.Connection
  ado_Ora.CursorLocation = adUseClient
  ado_Ora.Open strconn


- MySql 접속

  '선언부

  Dim RS_MS As ADODB.Recordset
  Dim ado_MS As ADODB.Connection

  '사용시
  Dim strconn As String

  strconn = "DRIVER={MySQL ODBC 3.51 Driver};server=servername;uid=userid;pwd=password;database=dbname;option=3;port=3306;STMT=SET NAMES EUCKR"

  Set ado_MS = New ADODB.Connection
  ado_MS.CursorLocation = adUseClient
  ado_MS.Open strconn
Posted by 현자

댓글을 달아 주세요

2010.04.08 14:01

VisualBasic 파일 입출력 Language/VB2010.04.08 14:01

' 파일 입력 예제   
    Dim f As Integer
    Dim str As String
       
    f = FreeFile()
   
    Open App.Path & "\config.ini" For Input As #f
        Line Input #f, server
        Line Input #f, ID
        Line Input #f, pw
        Line Input #f, str
        cycleTime = str
       
    Close #f


' 파일 출력 예제
    Dim f As Integer
       
    f = FreeFile()
    Open App.Path & "\Log\" & Replace(Date, "-", "") & "_Log_Err.txt" For Append As #f
        Print #f, Date & " " & Format(Time, "hh:mm:ss") & "   " & str
    Close #f
Posted by 현자

댓글을 달아 주세요

2010.04.08 13:20

VisualBasic 폼의 투명도 설정하기 Language/VB2010.04.08 13:20

' 선언부
' ### 투명화 관련
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

' 사용시
MakeLayeredWnd Me.hWnd
SetLayeredWindowAttributes Me.hWnd, 0, 255 * (투명도), LWA_ALPHA
Posted by 현자

댓글을 달아 주세요

2010.04.08 12:42

VisualBasic 폼을 원으로 만들기 Language/VB2010.04.08 12:42

' 선언부

' ### 폼 원형으로 설정
Private Declare Function CreateEllipticRgn Lib "gdi32.dll" ( _
    ByVal X1 As Long, _
    ByVal Y1 As Long, _
    ByVal X2 As Long, _
    ByVal Y2 As Long _
) As Long
Private Declare Function SetWindowRgn Lib "user32.dll" ( _
    ByVal hWnd As Long, _
    ByVal hRgn As Long, _
    ByVal bRedraw As Boolean _
) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" ( _
    ByVal hObject As Long _
) As Long

' 사용시

' ### 폼을 둥글게 설정한다.
Dim hRgn As Long
hRgn = CreateEllipticRgn(0, 0, ScaleX(Me.Width, vbTwips, vbPixels), ScaleY(Me.Height, vbTwips, vbPixels))
SetWindowRgn hWnd, hRgn, False
DeleteObject hRgn
Posted by 현자

댓글을 달아 주세요