5 replies
by carolmwde Accepted solution
by Member 19076783 Accepted solution
If using vb and a simple sql there are a couple of ways
one is via odbc which you will need to set up if you host is external
The other is via sql server management studio
by mcymerman Accepted solution
The easiest is to create a connection using a connection string as in:
Dim RSAccess As ADODB.Recordset
Dim sConnect As String
Dim ssQL As String
Dim SQLConn As ADODB.Connection
' set strings to connect
sConnect = "Provider=MSDASQL.1;Extended Properties='DRIVER=SQL Server;SERVER=YourServer;UID=;PWD=;APP=Visual Basic;WSID=NMIUser;DATABASE=YourDatabase;Trusted_Connection=Yes'"
ssQL = "Select Customer from YourTable"
' open connection
Set SQLConn = New Connection
SQLConn.Open sConnect
' create a recordset for a Database table
Set RSAccess = New Recordset
RSAccess.CursorLocation = adUseClient
RSAccess.Open ssQL, SQLConn, adOpenForwardOnly, adLockReadOnly
by dma69593 Accepted solution
To connect to the database in VB, go the the Tools|Connect to Database menu command. This will display the Choose Data Source dialog box.
This box will list the different database formats. You need to select the source of the data eg if its an Access database select MS Access and so on.
Then select the Data provider in the drop down list below.
click continue.
The Add Connection dialog box should now appear. Use the browse button to find the file. Once you do this, the path to and the name of the database should appear in the Database File Name text box.
The next step is to test the connection.
(Always the nailbiting bit!)
All things going well, a message box should appear saying Test Connection succeeded.
Click OK.
I hope this works for you.
regards
by granttatira Accepted solution
This discussion is closed to new replies.
Trending Windows Forum posts
Sort by Trending