Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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 & "'"

Reply With Quote
  #2 (permalink)  
Old January 28th, 2006, 07:57 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

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.


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....

Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 06:10 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.