I’m using the following snippit of code to update an entry:
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
With SqlDataSource1
.UpdateParameters("id").DefaultValue = Request.QueryString("id")
.UpdateParameters("pageContent").DefaultValue = edittor.Content
.Update()
End With
End Sub
The problem is that is says
.UpdateParameters("id").DefaultValue
Object reference not set to an instance of an object.
I’ve used it this way before (I think). Could somebody please explain why this is messed up OR, because I’ve noticed that most people do it straight in the SQL, how to do this the correct way (i.e. updating an entry in my table).
This is not the best solution but you can try this one. For this you should not include that parameter in .aspx page otherwise it will throw an error.
First Method:
Second Method:
Specify parameters OnUpdating Event of SqlDataSource