About Syed Adeel Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include XML, Custom Controls + Computer Hardware and Windows Turboshooting...etc.
More Skills :
1 . PHP - > All Type Of CMS e.g. (Joomla,Drupul,PHPNuke...etc)
2 . ASP
3 . ASP.Net
4 . CMS
5 . MySql
6 . SQl Server 2000 & 2005
7 . Ms Access
8 . Web Designing
9 . Networking Turboshooting
10 . Windows Turboshooting
11 . Hardware Turboshooting
All Type Of Work Related To IT
I also Do Work as a Freelance as Application & Web Developer & Designer
Experience i have 3 years work experience in software house and 4 years work experience for computer hardware and Networking..
Expert: Syed Adeel Rizvi Date: 4/8/2008 Subject: Another error message I dont understand
Question Hi Ravi,
I am trying to update a table in a database that has four field of which there is no primary key. I successfully call up the information and amend it but when I click submit I get an error message. This method works fine in other pages I have coded but I am unsure why it does not on this page - I susspect that its something to do with the database but can't pin point the fault.
I have attatched the code and error message, thanks in advance Ravi your a life saver!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If User.Identity.IsAuthenticated = False Then
Server.Transfer("~/Website/Unauthorised.aspx")
End If
Con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Project\database\Backend.mdb"
'Opens the connection to the database
Con.Open()
'This is table spercific
sqlIPAddress = "SELECT * FROM tbl_IPAddresses WHERE Tag = '" + Request("Tag") + "';"
da = New Data.OleDb.OleDbDataAdapter(sqlIPAddress, Con)
da.Fill(ds, "AmendIPAddress")
Con.Close()
End Sub
Protected Sub cbDHCP_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
If cbDHCP.Checked = True Then
txtIPAddress.Text = ""
txtIPAddress.Enabled = False
Else
txtIPAddress.Enabled = True
End If
End Sub
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("~/Website/Administration/Ammend/PC/AmendPC.aspx")
End Sub
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Project\database\Backend.mdb"
'Opens the connection to the database
Con.Open()
'This is table spercific
sqlIPAddress = "SELECT * FROM tbl_IPAddresses WHERE Tag = '" + Request("Tag") + "';"
da = New Data.OleDb.OleDbDataAdapter(sqlIPAddress, Con)
da.Fill(ds, "AmendIPAddress")
Dim cb As New Data.OleDb.OleDbCommandBuilder(da)
ds.Tables("AmendIPAddress").Rows(0).Item(0) = txtTag.Text
ds.Tables("AmendIPAddress").Rows(0).Item(1) = txtIPAddress.Text
ds.Tables("AmendIPAddress").Rows(0).Item(2) = txtType.Text
ds.Tables("AmendIPAddress").Rows(0).Item(3) = cbDHCP.Checked
da.Update(ds, "AmendIPAddress")
Con.Close()
'Response.Redirect("~/Website/Administration/Ammend/PC/AmendPC.aspx")
End Sub
Protected Sub btnAmend_Click(ByVal sender As Object, ByVal e As System.EventArgs)
txtTag.Text = ds.Tables("AmendIPAddress").Rows(0).Item(0)
txtIPAddress.Text = ds.Tables("AmendIPAddress").Rows(0).Item(1)
txtType.Text = ds.Tables("AmendIPAddress").Rows(0).Item(2)
cbDHCP.Checked = ds.Tables("AmendIPAddress").Rows(0).Item(3)
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
Source Error:
Line 53: ds.Tables("AmendIPAddress").Rows(0).Item(2) = txtType.Text
Line 54: ds.Tables("AmendIPAddress").Rows(0).Item(3) = cbDHCP.Checked
Line 55: da.Update(ds, "AmendIPAddress")
Line 56: Con.Close()
Line 57:
[InvalidOperationException: Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.]
System.Data.Common.DbDataAdapter.UpdatingRowStatusErrors(RowUpdatingEventArgs rowUpdatedEvent, DataRow dataRow) +196
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +662
System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable dataTable, DataTableMapping tableMapping) +41
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) +181
ASP.website_administration_ammend_pc_amendpcip_aspx.btnSubmit_Click(Object sender, EventArgs e) in C:\Project\WebSite\Website\Administration\Ammend\PC\AmendPCIP.aspx:55
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +97
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4921
Many Thanks
Ben
Answer Hello,
try to put this
after this
ds.Tables("AmendIPAddress").Rows(0).Item(2) = txtType.Text
ds.Tables("AmendIPAddress").Rows(0).Item(3) = cbDHCP.Checked
ds.AcceptChanges() '-<this new word
da.Update(ds, "AmendIPAddress")