There wasnt any problem with the settings. Now I have succeeded in updating simple database via OleDBDataAdapter and OleDbCommandBuilder objects but the same code is not working when I am using to update too many columns. Actually I cant figure out the error in my following code.
dim conn as new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Inetpub\wwwroot\website\visitor.mdb")
Dim cmd As OleDbDataAdapter
Dim ds As New DataSet()
Dim dr As DataRow
sub submit_clicked(Sender as object, e as Eventargs)
dim i,j as integer
dim str as string
'dim countrystr, tourstr as string
dim param(7) as string
dim flag as boolean=true
'Inserting values from text boxes into a string array
j=0
for i=0 to panel1.controls.count-1
if panel1.controls(i).GetType Is GetType(textbox) then
str=Ctype(panel1.controls(i),textbox).text
if str <> "" then
param(j)=str
else
flag=false
label1.text="forgot to enter value for " & panel1.controls(i).id
end if
j=j+1
end if
next
if not flag then
exit sub
end if
try
cmd = New OleDbDataAdapter(New OleDbCommand("select * from visitors",conn))
Dim comb As OleDbCommandBuilder = New OleDbCommandBuilder(cmd)
conn.Open()
cmd.fill(ds,"visitorinfo1")
dr = ds.Tables("visitors").NewRow()
catch ex as exception
label1.text="Error in updating database"
end try
'Entering values in datarow from textboxes
dr("Name") = param(0)
dr("Email") = param(1)
if rdbgender.SelectedIndex = 0
dr("Gender") = "Male"
else
dr("Gender") = "Female"
end if
dr("Age") = param(2)
dr("Address") = param(3)
dr("Phone No") = param(4)
countrystr = ddlcountry.SelectedItem.Text
dr("Country") = countrystr
dr("Tour Type") = rdbtour.SelectedItem.Text
tourstr = lbdetails.SelectedItem.Text
dr("Tour Detail") = tourstr
dr("Custom Tour") = param(5)
dr("No of Travellers") = param(6)
ds.Tables("visitors").Rows.Add(dr)
cmd.Update(ds, "visitors")
label1.text="database updated"
end sub
Name, Age, ...... are the names of columns in database table in Access
ddlcountry and ddldetails are the id's of dropdownlist controls
rdbtour is id of the radiobutton control in html part of page.
Now with this code I am having problem on the linecmd.Update(ds, "visitor")
Error is
Syntax error in INSERT INTO statement
If anyone can figureout the error in this code plz let me know. I will be thankful.