any wizard help to connect to the database in vb6? vb .net does hav wizard help in connecting to database. feels strange suddenly go backward.
Printable View
any wizard help to connect to the database in vb6? vb .net does hav wizard help in connecting to database. feels strange suddenly go backward.
I use Access with DB6 all the time. You have to create a data environment with the info about the database first and then you can create objects that connect to the environment (fields, sliders, grids, etc...)
Lance
well, im using Ms SQL Server. could anyone can giv some example code which showing the way of connecting to the database?
Heres how i have done it...
In a Module (just cause i use the connections through out my project)...
You will have to change 'DBASE_NAME' and 'YOURPASSWORD' along with the I.P.
1433 is the SQL port.Code:Global Const Dbase = "Provider=sqloledb;" & _
"Data Source=192.168.0.11,1433;" & _
"Network Library=DBMSSOCN;" & _
"Initial Catalog=DBASE_NAME;" & _
"User ID=sa;Password=YOURPASSWORD;"""
Public cn As ADODB.Connection
Public rs As ADODB.Recordset
Then in the form...Code:Set cn = New ADODB.Connection
cn.Open Dbase
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM TABLE_NAME", cn, adOpenStatic, adCmdText
Do Until rs.EOF
Text1.text = rs.Fields("Col_Name") & vbcrlf
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
_
IP address must put my IP follow by 1433? What is adOpenStatic and adCmdText?