What I ask can be very familiar to most of you. So, please don't point me a URL in MSDN, I can't understand the stuff there. Instead please add the "lacking" codes and help me to complete the code.I need to store First Name and Last Name of userswhich come as user inputs through text boxes in a web form to an existing data table as a new data row.I used DataSets. I heard it is bulky. Is there any otherway of achieving it? I have included the databaseconnection in a method that is called for the clickevent of the submit button. Instead, Should I includeit in the Page load event? I also want to know weather there is a way to give relative paths for database connection instead of an absolute one which won't be practical when I move the stuff to a web server.Below I have included the complete code even withHTML. The error I get is "Update requires a valid InsertCommand when passed DataRow collection with new rows"It occurs due to the statement,objCmd.Update(ds, "contacts")Please help me to complete the code. I am a trainee and this is a practice project thatI should submit. I couldn't complete it for2 weeks. I made forum posts and got MSDNlinks. Please don't do that. Just tell me what code to where I should add. I really appreciate yourhelp. Here is the code,sub Add(obj as object, e as EventArgs)dim objConn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\users\database\users.mdb")objConn.Open()dim objCmd as new OleDbDataAdapter("select * from contacts", objConn)dim ds as DataSet = new DataSet()objCmd.Fill(ds, "contacts")dim dr as DataRow = ds.Tables("contacts").NewRow()dr(1)=txtFirstName.textdr(2)=txtLastName.Textds.Tables("contacts").Rows.Add(dr)objCmd.Update(ds, "contacts")objConn.Close()end sub First Name Last Name
vbgaya 0 Newbie Poster
hollystyles 113 Veteran Poster
vbgaya 0 Newbie Poster
vbgaya 0 Newbie Poster
hollystyles 113 Veteran Poster
vbgaya 0 Newbie Poster
hollystyles 113 Veteran Poster
WolfPack commented: good help. carry on. :) +3
vbgaya commented: Great!!! +1
vbgaya 0 Newbie Poster
hollystyles 113 Veteran Poster
vbgaya 0 Newbie Poster
nunnakk 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.