7 messages in com.mysql.lists.win32RE: Correct syntax for 'insert'ing data
FromSent OnAttachments
Ron Smith21 Apr 2005 12:43 
Randy Clamons21 Apr 2005 13:00 
jbon...@sola.com.au21 Apr 2005 15:49 
Ron Smith21 Apr 2005 15:58 
Ron Smith21 Apr 2005 16:09 
Randy Clamons21 Apr 2005 17:26 
jbon...@sola.com.au25 Apr 2005 15:45 
Subject:RE: Correct syntax for 'insert'ing data
From:Ron Smith (geek@yahoo.com)
Date:04/21/2005 04:09:00 PM
List:com.mysql.lists.win32

Thanks David,

"jbonnett" and "Randy", from the list, came up with a solution that works for
me. However, I'm keeping what you sent me because it looks to me like another
way of setting things up. Thanks for the tip.

Ron

David Parham <davi@dpan.net> wrote: This absolutely drove me crazy last week when I was trying to do this in a VB app. I had the best MySQL guys I knew look at it, and no one could give me a clue as to what was happening. I'm not sure what fixed it for sure, but once I opened the database manually in the code and did the update with ado recordset, and then CLOSED the recordset, all my problems went away. I had earlier tried to use the ADO control that we use to populate a grid. The code that works for me now is:

Dim conn As ADODB.Connection Dim rs As ADODB.Recordset

Dim sql As String

Set conn = New ADODB.Connection conn.ConnectionString = " DRIVER={mySQL ODBC 3.51 Driver} ;" _ & "SERVER=DELLLAPTOP2;" _ & "DATABASE=DPAMYSQL; " _ & "UID=root;PWD=xxxx; OPTION=3"

conn.Open

Set rs = New ADODB.Recordset rs.CursorLocation = adUseServer rs.CursorType = adOpenDynamic rs.LockType = adLockOptimistic selstring = "select * from todo where tdunq = " & txttdunq rs.Open selstring, conn

If rs.EOF Then rs.AddNew End If

With rs !tdcid = txttdcid !tdunq = txttdunq !tddat = txttddat !tdmem = txttdmem !tdln1 = txttdmem !tdcom = txttdcom !tdpri = txttdpri !tdprj = txttdprj !tddel = txttddel .Update .UpdateBatch End With

rs.Close

msg = "Record Updated"

I am still using the ADO record set to refresh the grid... Both reference the same file. This is the code below the above code to move me to the next record in the file and populate the unbound fields to the work fields.

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast msg = "End of File Encountered.. showing last record " MsgBox (msg) End If Call DIMoveFs Form1.txttdcid.SetFocus Form1.Refresh

I know this is VB code and not access, but I'll bet if you close and reopen the recordset, your problem will clear up.

Hope this helps,

David Parham

-----Original Message----- From: Ron Smith [mailto:geek@yahoo.com] Sent: Thursday, April 21, 2005 2:44 PM To: MySQL Mailing List Subject: Correct syntax for 'insert'ing data

I'm having problems with the syntax for entering data. I'm using:

objRS.AddNew objRS("Name") = name objRS("Address") = address objRS("City") = city objRS("State") = state objRS("Zip") = zip objRS("Phone") = phone objRS.Update

for an "MS Access" database.

What would be the correct syntax adding to a MySQL database.

I was using:

sql="insert into contact_info.friends (Name, Address, City, State, Zip, Phone) values (name, address, city, state, zip, phone)" set objRS=objConn.execute(sql)

but it errors out.