Re: INSERT statement using variables

From: Herfried K. Wagner [MVP] (hirf-spam-me-here_at_gmx.at)
Date: 11/02/04


Date: Tue, 2 Nov 2004 12:15:00 +0100


"sm" <sm@discussions.microsoft.com> schrieb:
> Can anybody give me the syntax to insert a record into
> SQL server through VB code using variables?
>
> The following statement is failing!
> sInsertQuery = "INSERT INTO TestTab (Col1, Col2, Col3, Col4) Values(" & _
> str1 & "," & dt1 & "," & str2 & "," & str3 & ")"

Use an 'InsertCommand' + parameters instead:

Using Parameters with a 'DataAdapter'
<URL:http://msdn.microsoft.com/library/en-us/cpguide/html/cpconusingparameterswithdataadapters.asp>

-- 
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/> 


Relevant Pages

  • Re: select case in stored procedure ?
    ... infact, i got several column may be update (which depends on the case ... it seems wrong syntax if my code like this:- ... > Vyas, MVP (SQL Server) ...
    (microsoft.public.sqlserver.programming)
  • Re: Creating a object of a wrapper dll class
    ... "sm" schrieb: ... > What is the syntax to create an instance of a class present ... What wrapper DLL? ... Herfried K. Wagner [MVP] ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Is Access SQL FROM Clause different from MS SQL Server SQL?
    ... The specific question about tbl4 in this query can be answered. ... syntax and functionality of this is the same as in SQL Server. ... CROSS JOIN in SQL Server's Books Online, ... The syntax of representing a CROSS JOIN by just a comma may be less ...
    (microsoft.public.access.queries)
  • RE: Access project vs. Access db
    ... Because the syntax you are using is asking the database engine to compare ... Jet won't warn you of this logic error, but SQL Server does. ... Where can I get general/ongoing help with what may be a host of these ...
    (microsoft.public.access.modulesdaovba)
  • Re: HELP! UPDATE syntax that work in sql server and access vba
    ... When you are working with Access ODBC linked tables, you must use the JET ... You should ask in a newsgroup about queries under Access how to ... In sql server I use syntax as follow: ... I also tried the following syntax in access query: ...
    (microsoft.public.access.adp.sqlserver)