Visual Basic Development Bookmark and Share   
 Home > Visual Basic Language > Help with ODBC Command
 

Help with ODBC Command

I built a small program that reads in a text file and stores information from that text file in DIMed variables. I built an ODBC Command using the wizard (dragging the ODBC Command method onto the form). How do I pass the variables to the SQL string? I have INSERT INTO tblname (field1, field2) VALUES ( xx ) as the command named cmdInsertData. WHat do I put in the XX ? The VB variable name? Then do I just call the cmdInsertData.commandtext in the code? I can't find any examples like this.

Thanks

agentfox1942  Tuesday, July 31, 2007 4:58 PM
Hi there,
See here about adding parameters to your command in ODBC:
http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcparametercollection(vs.80).aspx

Good luck.
nmadd  Tuesday, July 31, 2007 8:45 PM

Access the Parameters collection of the Command object in order to add the necessary parameters. The exact syntax of the parameter names in the CommandTextmayn depend on the underlying datasource (or ODBC driver settings). Please see the MSDN documentation on the System.Data.Odbc.OdbcCommand object.

Reed Kimble  Wednesday, August 01, 2007 5:29 PM
Hi there,
See here about adding parameters to your command in ODBC:
http://msdn2.microsoft.com/en-us/library/system.data.odbc.odbcparametercollection(vs.80).aspx

Good luck.
nmadd  Tuesday, July 31, 2007 8:45 PM
Thanks. I'll give that a shot. I wanted to do it with a stored procedure, but if this works, great. There has to be an easy way to just pass the variables into the INSERT INTO command directly from VB. I'm just missing it. I have the command created but I don't know how to call it. I dragged the ODBC COmmand onto the form, created it that way. Thanks again.

agentfox1942  Wednesday, August 01, 2007 11:43 AM

Access the Parameters collection of the Command object in order to add the necessary parameters. The exact syntax of the parameter names in the CommandTextmayn depend on the underlying datasource (or ODBC driver settings). Please see the MSDN documentation on the System.Data.Odbc.OdbcCommand object.

Reed Kimble  Wednesday, August 01, 2007 5:29 PM

You can use google to search for other answers

Custom Search

More Threads

• How to delete tab spaces in a file?
• Control Arrays with Labels, Textboxes, etc...
• TEXT FILE - HELP !!!!
• A Few Questions (VB, Studio 05)
• System.stackoverflow exeption
• ContextMenuStrip and 3rd party control
• Multilanguage Application
• Date in UTC format in batch file
• VB 6 and WinForm
• Dont know how to go back to the visual form editor.. pls help me...