Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Program from Using Ado to SQL

Status
Not open for further replies.

kennedymr2

Programmer
May 23, 2001
594
AU
I have set up a test set of code to connect to an sql database as follows.
It works fine!!!


Dim sqlconnect As Object
Dim sqldata As Object
Dim strSQL As String
Set sqlconnect = CreateObject("ADODB.Connection")
sqlconnect.Open "Driver={SQL Server};Server=tcs\test;Database=northwindcs1;uid=sa;pwd=foo;"
strSQL = "SELECT * FROM customers"
Set sqldata = sqlconnect.Execute(strSQL)

While sqldata.BOF = False And sqldata.EOF = False
varresult = sqldata("customerid")
varResult2 = sqldata("companyname")
Listbox1.AddItem varresult & " " & varResult2
sqldata.MoveNext
Wend



sqldata.MoveFirst

ok to here...... then ERROR !@!@!@!@!@@!!@!@

sqldata.Edit

ERROR = object does not support this property or method

sqldata("customerid") = "1212"
sqldata.update



================

ie i have a large program written in ado but now have to use an sql database
do not wish to alter the code to much
can the above code be altered to allow these functions under sql

appreciate any help
 
Have a look at my data access faq222-2103.

Basically, using a dsn, you can switch to a different type of database at the dsn, never touching your code. Ie use access, sql server, oracle etc.

Jonathan Galpin MCSD
because software should be easy to use
 
ADO doesn't support the Edit Method - DAO does. Just change the values and do the update.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Appreciate the help offered.
I put the edit command in by mistake, sorry for the error.
Will have a good look at the dsn idea, it will save me a lot of work and worry if i do it this way.
Sql looks complicated.

regards kennedymr2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top