How to connect MS SQL and Visual Basic 6.0

Asked By 0 points N/A Posted on -
qa-featured

Good Day,

I want to know how to connect using MS SQL and Visual basic 6.0.

Most of the time I used Access database, but I want a database that can handle a large data so I choose an MS SQL database.

Please help me what is the connection string.

SHARE
Answered By 0 points N/A #161483

How to connect MS SQL and Visual Basic 6.0

qa-featured

Well,

Just refer to ADO this is done by going through menu ->project->preferences. Then check the check box of Microsoft Active X Data Objects 2.X Library. (MDAC Installed).

Then establish connection objects by this command set. The intensive will give you this utility, so install it.

Dim     connection      As        New     ADODB.Connection

Dim     Command       As        New     ADODB.Command

Then have login follow these steps (command)

Connection.ConnectionString = "driver={SQL Server};server=YOURSERVER;uid=YOURUSER;pwd=YOUPASS WORD;database=YOURDATABASE"
Connection.Open
Command.ActiveConnection = Connection

Procedure Call by this command

Dim ResultSet As New ADODB.Recordset
Command.CommandText = "YOURPROCEDURE"
Set ResultSet = Command.Execute

Work with your results

Dim value as String
If ResultSet.BOF = True And ResultSet.EOF = True Then
Value = ResultSet. Fields (0)

End If

Related Questions