|
-
May 8th, 2002, 09:19 PM
#1
Thread Starter
New Member
me going ado
i have decided (finaly) 2 go with ado instead of dao (which i have been using 4 ages).. so could someone give me the easyest possible way 2 get and set a record in a database with ado??
thnx
-
May 8th, 2002, 09:27 PM
#2
PowerPoster
You would get more answers if you ask this question in "Database Development" forum but you can try an introductory tutorial for ADO by Beacon here:
http://www.vbforums.com/showthread.php?threadid=153935
-
May 8th, 2002, 09:28 PM
#3
Try something like this.. Its as easy as it was before with DAO.
VB Code:
Dim conn As New ADODB.Connection
Dim sql As String
sql = "INSERT INTO TableName(ColumnName1, ColumnName2) VALUES(value1, value2)"
conn.ConnectionString = "SomeDSNName"
conn.Execute sql
ADO is "almost" exactly like DAO... You should have no major progrems getting used to it.
Check out some of there.. They should help.
http://www.w3schools.com/ado/default.asp
-
May 8th, 2002, 09:30 PM
#4
-
May 8th, 2002, 09:40 PM
#5
Arc,
Actually your going to need a bit more than that.
Rs con, SQLString
Rs needs to know what connection to use.
Also you dont need to use a recordset object just to execute a SQL statement. I dont need to be soo picky though
-
May 8th, 2002, 09:48 PM
#6
Junior Member
Select reference Microsoft ADO 2.0 Library
Dim con as Connection
Dim rs as recordset
Set con=new Connection
Set rs=new Recordset
With con
.ConnectionString "User id=whatever is the user;pwd=what eve rpassword;data source=where the database is(machine name);Initial catalog=the name of the database
.Provider="the provider name" For eg: for SQL SQLOLEDB
.Open
End With
rs.open "the query statement",con
-
May 8th, 2002, 10:13 PM
#7
PowerPoster
Nice work abdul!
To the others the reason there's a tutorial is so you dont have to explain it all.
-
May 9th, 2002, 01:34 PM
#8
PowerPoster
Originally posted by joan_fl
Arc,
Actually your going to need a bit more than that.
Rs con, SQLString
Rs needs to know what connection to use.
Also you dont need to use a recordset object just to execute a SQL statement. I dont need to be soo picky though
joan you are right about the con object having to be specified, I forgot to add that on, however you put it in the wrong place. It comes after the SQLString. Rs SQLString, con. You are also correct about not having to use the Recordset Object to execute an SQL Statement, that's just my preference.
I Do have to ask you one question though. You Specified your connection String as a DSN. Do businesess really use DSN connections? I mean since it uses an ODBC driver instead of OLE DB i assumed it would not be used any more.
-We have enough youth. How about a fountain of "Smart"?
-If you can read this, thank a teacher....and since it's in English, thank a soldier.

-
May 9th, 2002, 01:44 PM
#9
I Do have to ask you one question though. You Specified your connection String as a DSN. Do businesess really use DSN connections? I mean since it uses an ODBC driver instead of OLE DB i assumed it would not be used any more.
DSNs are still used out there... there soo many older programs out there. Though your right.. I would think any new development would use a dsnLESS connection though with OLEDB.
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
|