달력

10

« 2019/10 »

  •  
  •  
  • 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
  • 31
  •  
  •  
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 현자

댓글을 달아 주세요