Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
| Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 28th, 2006, 01:51 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Insert row into MS-ACCESS database

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,projectedcomp letiondate,contractpo#,contractproject#,Generalcon tractor,generalcontractorjob#,owner,ourcontractwit h,contractPM,ourprojectmanager,ourpmcellphone,site street,sitecity,sitestate,sitezip,basepoamount,cha ngeordertotal,contracttodate,basesubcontracts,subc ontractcosttodate,retainage,latecharges,warranty,o cip,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 & "'"




 
Old January 28th, 2006, 07:57 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in inserting a new row in MS Access yzlin04 VB.NET 2002/2003 Basics 2 July 18th, 2007 11:11 PM
Problem with inserting a new row in MS Access yzlin04 VB Databases Basics 0 July 15th, 2007 11:23 PM
Database migration MS Access 2003 to MS SQL 2000 ayazhoda SQL Server 2000 3 April 23rd, 2007 11:38 AM
Insert Row in Database monika.vasvani ASP.NET 1.0 and 1.1 Professional 1 November 18th, 2006 05:17 AM
insert row to database heathonbass C# 2 December 19th, 2004 01:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.