Updating Tables (again)

Updating Tables (again)

Post by Shawn Fess » Thu, 09 Dec 2004 00:40:14


Ok, this *** is still giving me fits. All I want to do is insert a record
into a MySQL database via VB/ADO/ODBC (MyODBC 3.51) *without* reading the
entire table first. Now the ODBC driver is returning "SQLBindParameter not
called for every parameter) - which I gather means that not all the
parameters were bound to the command. But the sql contains two ?s and the
command has two parameters. What's the problem? Do I have to escape the
question marks or something?

Sql = _
"insert into Messages (MID, From, Date, Subject, Body) " + _
"values (" + _
"'" + msg.ID + "'," + _
"'" + From + "'," + _
"'" + FormatDateTime(msg.TimeReceived) + "'," + _
"?," + _
"?" + _
")"

' K, now we're going to try to use params.
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = cn
cmd.CommandText = Sql
Set pSub = cmd.CreateParameter(, adVarChar, adParamInput, 100, msg.Subject)
Call cmd.Parameters.Append(pSub)
Set pBody = cmd.CreateParameter(, adLongVarChar, adParamInput, 16777215,
msg.Text)
Call cmd.Parameters.Append(pBody)
Call cn.Execute(sSql)
 
 
 

Updating Tables (again)

Post by SINGER Zol » Thu, 09 Dec 2004 04:32:08

I always use ADO, instead of T-SQ for DB manipulation...
To avoid getting the full table, I create an empty or little recordset as:
SELECT TOP 0 * FROM table

give a WHERE clause what you are sure that have not return any data...


"Shawn Fessenden" <shawn#no#@testech-ldt.#spam#com> az albiakat ta a

record
msg.Subject)