borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (when i should use remoting or webservice ?)Next Topic (about Oracle managed provider ? (ora)) New Topic New Poll Post Reply
AndreaVB Forum : ASP.Net : Encounter error at the time of inserting data to table?
Poster Message
tri_inn
Level: Regular User
Registered: 26-08-2002
Posts: 395

icon Encounter error at the time of inserting data to table?

i have simple webform which will insert data to ms-access2000 database but when i am going to insert data
in my table that i am getting one error repeatedly
that is 'Syntax error in INSERT INTO statement.'
just i can't understand what is wrong in my coding but when i am changing my database from
access2000 to Sqlserver2000 then it works fine.so it is getting confusing for me.
please tell me how could i fix the error.why i am getting error when my database is access2000 but
the same code works fine just when my database is sqlserver.is it a bug of asp.net.
please please tell me how could fixed the error when my database is access2000 because i am in
great problem.

i am simply giving you the only portion which will insert new record to access2000 database

my code follows
----------------

    Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("ScheduleDB.mdb"))
        'Dim cn As New OleDbConnection("Provider=SQLOLEDB.1;Password=sa;User ID=sa;Initial Catalog=pubs")

        Dim daAdd As New OleDbDataAdapter("select * from Myevent", cn)
        Dim drAdd As DataRow
        Dim dsAdd As New DataSet()
        Dim cmdAdd As OleDbCommandBuilder

        Try
            Dim tm() As String = Split(ddlTime.SelectedItem.Text, "-")
            cmdAdd = New OleDbCommandBuilder(daAdd)
            daAdd.Fill(dsAdd, "event")

            drAdd = dsAdd.Tables("event").NewRow
            drAdd("day") = ddlDay.SelectedItem.Text
            drAdd("month") = ddlMonth.SelectedItem.Text
            drAdd("year") = ddlYear.SelectedItem.Text
            drAdd("starttime") = tm(0)
            drAdd("endtime") = tm(1)
            drAdd("event_info") = txtEvent.Text
            dsAdd.Tables("event").Rows.Add(drAdd)
            daAdd.Update(dsAdd, "event")
            lblmsg.Visible = True
            lblmsg.Text = "1 Record inserted..."
            cn.Close()
        Catch ex As OleDbException
            lblmsg.Visible = True
            lblmsg.Text = ex.StackTrace.ToString
        End Try
    End Sub

16-08-2004 at 01:15 PM
View Profile Send Email to User Show All Posts | Quote Reply
johnedw
Level: Sage

Registered: 15-08-2004
Posts: 50
icon Re: Encounter error at the time of inserting data to table?

It appears that year is a reserved access keyword....
check this link out.

http://www.xlinesoft.com/asprunnerpro/articles/sql_access_odbc_reserved_keywords.htm

____________________________
Today is a new day, in
a world OF CODE!

16-08-2004 at 01:33 PM
View Profile Send Email to User Show All Posts ICQ | Quote Reply
AndreaVB Forum : ASP.Net : Encounter error at the time of inserting data to table?
Previous Topic (when i should use remoting or webservice ?)Next Topic (about Oracle managed provider ? (ora)) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder