•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,488 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,436 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5234 | Replies: 2
![]() |
•
•
Join Date: Aug 2006
Posts: 14
Reputation:
Rep Power: 3
Solved Threads: 0
I have written some coding to add a new row to
an existing data table. After clicking the submit
button I get following error.
"Update requires a valid InsertCommand when
passed DataRow collection with new rows."
Please tell me what the additional code I should
add. The "add" method is called after a user
clicking the submit button. I didn't include the
HTML stuff here.
Here is the code,
<script runat="server">
sub add(obj as object, e as EventArgs)
dim objConn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\scms\database\scms.mdb")
dim objCmd as new OleDbDataAdapter("select * from services", objConn)
dim ds as DataSet = new DataSet()
objCmd.Fill(ds, "services")
dim dr as DataRow = ds.Tables("services").NewRow()
dr(1)=txtServiceName.text
dr(2)=txtSinhalaShortTag.Text
dr(3)=txtTamilShortTag.Text
dr(4)=txtEnglishShortTag.Text
ds.Tables("services").Rows.Add(dr)
objCmd.Update(ds, "services")
end sub
</script>
Please help me. I can't figure out what to do.
vbgaya.
an existing data table. After clicking the submit
button I get following error.
"Update requires a valid InsertCommand when
passed DataRow collection with new rows."
Please tell me what the additional code I should
add. The "add" method is called after a user
clicking the submit button. I didn't include the
HTML stuff here.
Here is the code,
<script runat="server">
sub add(obj as object, e as EventArgs)
dim objConn as new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\scms\database\scms.mdb")
dim objCmd as new OleDbDataAdapter("select * from services", objConn)
dim ds as DataSet = new DataSet()
objCmd.Fill(ds, "services")
dim dr as DataRow = ds.Tables("services").NewRow()
dr(1)=txtServiceName.text
dr(2)=txtSinhalaShortTag.Text
dr(3)=txtTamilShortTag.Text
dr(4)=txtEnglishShortTag.Text
ds.Tables("services").Rows.Add(dr)
objCmd.Update(ds, "services")
end sub
</script>
Please help me. I can't figure out what to do.
vbgaya.
•
•
Join Date: Jun 2005
Location: Denmark, EU
Posts: 102
Reputation:
Rep Power: 4
Solved Threads: 3
There's no need to use DataSet for a simple operation like this.
This should do it:
This should do it:
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\scms\database\scms.mdb") : conn.Open()
Dim insCom As New OleDbCommand("INSERT INTO services (col1, col2, col3, col3) VALUES('" & txtServiceName.text & "', '" & txtSinhalaShortTag.Text & "', '" & txtTamilShortTag.Text & "', '" & txtEnglishShortTag.Text & "'", conn)
insCom.ExecuteNonQuery() Web Programmer
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net .net framework 3.0 access ajax asp breach code combo crime custom data data protection data transfer database developer development dom dropdownlist feed forensics government guid partition table hardware hitachi linux microsoft microsoft windows module msdn net news office reader reuse security skin software sql storage terabyte theme vista updates weather web wikipedia windows update windows vista windows workflow xml xoap
- insert and update data in two different database (JSP)
- how to delete data from table (MS SQL)
- converting data in a table into csv (comma separated) file (VB.NET)
- SQL Query to populate the data from Table to Forms (MS Access and FileMaker Pro)
- server notify client to update MySQL table (C)
- How can i deledet and update from table ??????? (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Format GridView Columns
- Next Thread: How to get the current web page information in asp.net?


Linear Mode