Subject: Insert row into MS-ACCESS database
Posted By: ITladybug Post Date: 1/28/2006 12:51:42 AM
I'm trying to insert new row into access table in vb.net.
Following code is giving me Syntax error for 'Insert into' statement. Please help me to solve this.
Dim strJobNo As String
    Dim strpm As String
    Dim strpmcell As String
    Dim strJobName As String
    Dim strSiteStreet As String
    Dim strSiteCity As String
    Dim intState As Integer
    Dim strZip As String
    Dim strGenContr As String
    Dim strGcProjId As String
    Dim strOwner As String
    Dim strStart As Date
    Dim strEnd As Date
    Dim intContWith As Integer
    Dim intContPm As Integer
    Dim strContPO As String
    Dim BasePoAmt As Double
    Dim strContPrjNo As String
    Dim contBillDt As String
    Dim intRetainage As Integer
    Dim strLiquidatedDmg As String
    Dim strWarranty As String
    Dim ocip As String
    Dim bond As String
    Dim eop As String
    Dim CoTotal As Double  'currency
    Dim CtoDt As Double 'currency
    Dim BaseSub As Double 'currency
    Dim intCnctwith As Integer
    Dim strCnctwith As String

myCommand.CommandText = "insert into MasterJobT(job#,jobname,jobstartdate,projectedcompletiondate,contractpo#,contractproject#,Generalcontractor,generalcontractorjob#,owner,ourcontractwith,contractPM,ourprojectmanager,ourpmcellphone,sitestreet,sitecity,sitestate,sitezip,basepoamount,changeordertotal,contracttodate,basesubcontracts,subcontractcosttodate,retainage,latecharges,warranty,ocip,equalopportunity,bonding,billdate)" _
                                                 & " values('" & strJobNo & "','" & strJobName & "',#" & strStart & "#,#" & strEnd & "#,'" & strContPO & "','" & strContPrjNo & "','" & strGenContr & "','" & strGcProjId & "','" & strOwner & "'," & intContWith & "," & intContPm & ",'" & strpm & "','" & strpmcell & "','" & strSiteStreet & "','" & strSiteCity & "'," & intState & ",'" & strZip & "'," & BasePoAmt & "," & CoTotal & "," & CtoDt & "," _
                                        & BaseSub & "," & SubTotal & "," & intRetainage & ",'" & strLiquidatedDmg & "','" & strWarranty & "','" & ocip & "','" & eop & "','" & bond & "','" & contBillDt & "'"




Reply By: Imar Reply Date: 1/28/2006 6:57:45 AM
Can you dump the contents of the CommandText to a label (or somewhere else on the page) and then post the result tot his list?

Maybe one or more values are missing, or your SQL is incorrect, but that's a lot easier to see with the complete SQL.

E.g.:

Label1.Text = myCommand.CommandText

provided you have a label called Label1.

Also, when you post more code in the future, can you please add a line break here and there? The page I typing this reply in, is now about a meter wide which isn't very practical....

Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.

Go to topic 39248

Return to index page 384
Return to index page 383
Return to index page 382
Return to index page 381
Return to index page 380
Return to index page 379
Return to index page 378
Return to index page 377
Return to index page 376
Return to index page 375