473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

adapter update problem Syntax error in INSERT INTO statement.

I am having trouble getting an adapter to update my access database, it
gives the error Syntax error in INSERT INTO statement. for
Line 98: Adapter.Update(WineDS, "tblWines")

Below is my code:

<%@ Control Explicit="True" Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
Dim ConnectString, SelectStatement As String
Dim Connect As OleDbConnection = New OleDbConnection
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter
Dim WineCB As OleDbCommandBuilder
Dim WineDS As DataSet = New DataSet
Dim Row As DataRow

Public IDNum As Integer
Public Region As String
Public Vintage As Integer
Public Type As String
Public Brand As String
Public Maker As String
Public YearToDrink As Integer
Public BestVintage As Integer
Public Food as String
Public Medals as String
Public Purchase as String
Public Value as String
Public Alchohol as Double
Public Website as String
Public Notes as String
Public Quantity as Integer
Public Bin as Integer

Public HasErrors As Boolean
Public RowError As String

Sub GetWine(IDSent As Integer)

SelectStatement = "Select * From tblWines Where IDNum=" & IDSent

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\aspnet\data\winelist.mdb"

Connect.ConnectionString = ConnectString

Adapter.SelectCommand = _
new OleDbCommand(SelectStatement, Connect)

Adapter.Fill(WineDS,"tblWines")

WineCB = New OleDbCommandBuilder(Adapter)

If WineDS.Tables("tblWines").Rows.Count > 0 Then
Row = WineDS.Tables("tblWines").Rows(0)

IDNum = Row.Item("IDNum")
Region = Row.Item("Region")
Vintage = Row.Item("Vintage")
Type = Row.Item("Type")
Brand = Row.Item("Brand")
Maker = Row.Item("Maker")
YearToDrink = Row.Item("YearToDrink")
BestVintage = Row.Item("BestVintage")
Food = Row.Item("Food")
Medals = Row.Item("Medals")
Purchase = String.Format("{0:c}", Row.Item("Purchase"))
Value = String.Format("{0:c}", Row.Item("Value"))
Alchohol = Row.Item("Alchohol")
Website = Row.Item("Website")
Notes = Row.Item("Notes")
Quantity = Row.Item("Quantity")
Bin = Row.Item("Bin")

BrandLabel.Text = Brand
TypeLabel.Text = Type
VintageLabel.Text = Vintage
NotesLabel.Text = Notes
FoodLabel.Text = Food
AlchoholLabel.Text = Alchohol
YearToDrinkLabel.Text = YearToDrink
BestVintageLabel.Text = BestVintage
RegionLabel.Text = Region
MakerLabel.Text = Maker
MedalsLabel.Text = Medals
PurchaseLabel.Text = Purchase
ValueLabel.Text = Value
WebsiteHyperLink.NavigateUrl = Website
WebsiteHyperLink.Text = Website
QuantityLabel.Text = Quantity
BinLabel.Text = Bin
End If

PostErrors
End Sub

Sub AddWine
Row = WineDS.Tables("tblWines").NewRow

CopyToDS
WineDS.Tables("tblWines").Rows.Add(Row)
Adapter.Update(WineDS, "tblWines")
PostErrors
End Sub

Sub EditWine
CopyToDS
Adapter.Update(WineDS, "tblWines")
PostErrors
End Sub

Sub RemoveWine
WineDS.Tables("tblWines").Rows(0).Delete
Adapter.Update(WineDS, "tblWines")
PostErrors
End Sub
' Copy the values in the properties of this
' control in the WineDS
Private Sub CopyToDS
Row.Item("IDNum") = CStr(IDNum)
Row.Item("Region") = CStr(Region)
Row.Item("Vintage") = CInt(Vintage)
Row.Item("Type") = CStr(Type)
Row.Item("Brand") = CStr(Brand)
Row.Item("Maker") = CStr(Maker)
Row.Item("YearToDrink") = CInt(YearToDrink)
Row.Item("BestVintage") = CInt(BestVintage)
Row.Item("Food") = CStr(Food)
Row.Item("Medals") = CStr(Medals)
Row.Item("Purchase") = CSng(Purchase)
Row.Item("Value") = CSng(Value)
Row.Item("Alchohol") = CSng(Alchohol)
Row.Item("Website") = CStr(Website)
Row.Item("Notes") = CStr(Notes)
Row.Item("Quantity") = CInt(Quantity)
Row.Item("Bin") = CInt(Bin)
End Sub

Private Sub PostErrors
HasErrors = WineDS.HasErrors
If HasErrors Then
RowError = WineDS.Tables("tblWines").Rows(0).RowError
End If
End Sub

</script>
<table border=1 width=100% bordercolor=#FFFFFF
cellspacing=0 cellpadding=2 bgcolor=#990000>
<tr>
<td bgcolor=#990000 colspan=2><font color="#FFFF00"><asp:label
id="BrandLabel" runat="server"
font-size="12 pt" font-bold="true" /> <asp:label id="TypeLabel"
runat="server"
font-size="12 pt" font-bold="true" /> <asp:label id="VintageLabel"
runat="server"
font-size="12 pt" font-bold="true" /></font> </td>
</tr>
<tr>
<td width=25% valign=top><font color="#FFFFFF">Notes:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="NotesLabel" runat="server"
font-size="12 pt" /> </font></td>
</tr>
<tr>
<td width=25%><font color="#FFFFFF">Food Suggestion:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="FoodLabel" runat="server"
font-size="12 pt" /> </font></td>
</tr>
<tr>
<td width=25%><font color="#FFFFFF">Alchohol Content:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="AlchoholLabel" runat="server"
font-size="12 pt" /> % </font></td>
</tr>
<tr>
<td width=25%><font color="#FFFFFF">Best Year To Drink:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="YearToDrinkLabel" runat="server"
font-size="12 pt" /> </font></td>
</tr>
<tr>
<td width=25%><font color="#FFFFFF">Best Vintage:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="BestVintageLabel" runat="server"
font-size="12 pt" /> </font></td>
</tr>
<tr>
<td width=25%><font color="#FFFFFF">Region:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="RegionLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Wine Maker:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="MakerLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Medals Won:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="MedalsLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Purchase Price:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="PurchaseLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Value:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="ValueLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Website:</font></td>
<td> <font color="#FFFFFF"><asp:hyperlink id="WebsiteHyperLink"
runat="server" target='_blank"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Quantity:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="QuantityLabel" runat="server"
font-size="12 pt" /> </font>
<tr>
<td width=25%><font color="#FFFFFF">Bin:</font></td>
<td> <font color="#FFFFFF">
<asp:label id="BinLabel" runat="server"
font-size="12 pt" /> </font></td>
</tr>
</table>
Nov 18 '05 #1
0 1752

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Keith Kuwatani | last post by:
I am using the ODBC .net provider against a pervasive 2000i database. The Data Adapter successfully generates Table Mapping, Select Statement and Insert Statement. However, the Update and Delete...
17
by: Benoit Martin | last post by:
I'm working on a project in VB.net connecting to a SQL Server 2000 database that I can't modify I created a dataset with a schema identical to the DB. When trying to update the DB from the dataset...
15
by: graham | last post by:
Hi all, <bitching and moaning section> I am asking for any help I can get here... I am at the end of my tether... I don;t consider myself a genius in any way whatsoever, but I do believe I have...
5
by: Al | last post by:
Hi, I need to update tables in access 97. The table names have spaces (not my choice). My update fails even though I use the OleDbCommandBuilder. Here is a code I am using myDataAdapter = New...
10
by: cj | last post by:
I'm having a problem writing an insert command to work with a datatable. I've looked at what the sqldataadapter creates and created my insert command to look the same. I have:...
1
by: cindy | last post by:
this is the call private void Page_Load(object sender, System.EventArgs e) { OdbcConnection connection = new OdbcConnection ("DSN=PFW52"); CreateDataAdapter(connection); } this is the code,...
2
by: travhale | last post by:
in a new project using .net 2005, c#. getting err message "Update requires a valid UpdateCommand when passed DataRow collection with modified rows." source RDBMS is oracle 8i. I add a new...
3
by: optictygre | last post by:
Hi folks. I have a couple questions about updating data from a dataset to a database using a data adapter. If I declare an adapter, set the batchupdatesize property to 0, and then call the...
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.