agentfox1942

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



Re: Visual Basic Language Help with ODBC Command

nmadd

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.




Re: Visual Basic Language Help with ODBC Command

agentfox1942

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.





Re: Visual Basic Language Help with ODBC Command

rkimble

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