|
-
Jan 24th, 2005, 03:36 AM
#1
Thread Starter
Hyperactive Member
connect to Ms SQL Server DB ! [resolved]
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.
Last edited by babyekc; Jan 28th, 2005 at 02:29 AM.
*wink wink*
_babyekc
-
Jan 24th, 2005, 03:51 AM
#2
New Member
Re: connect to DB !
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
-
Jan 24th, 2005, 03:53 AM
#3
Thread Starter
Hyperactive Member
Re: connect to DB !
well, im using Ms SQL Server. could anyone can giv some example code which showing the way of connecting to the database?
-
Jan 24th, 2005, 04:43 AM
#4
Lively Member
Re: connect to Ms SQL Server DB !
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
_
~ What was once an opinion, became a fact, to be later proven wrong... ~
-
Jan 25th, 2005, 08:40 PM
#5
Thread Starter
Hyperactive Member
Re: connect to Ms SQL Server DB !
IP address must put my IP follow by 1433? What is adOpenStatic and adCmdText?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|