i dont know if it is just because im tired or what. im trying to do a update one this table here is the stored procedure im using
ALTER PROCEDURE Snake.UpdateSPlits @.name nvarchar(50),@.splitnvarchar(50)ASUpdate accountsSet split_id = @.splitWhere name = @.name RETURN
Here is what im using to call it
Protected Sub GridView1_RowUpdating(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewUpdateEventArgs)Handles GridView1.RowUpdatingMe.SqlDataSource1.UpdateParameters.Clear()Dim nameAs String =Me.GridView1.SelectedRow.Cells(0).TextDim SplitAs String =Me.GridView1.SelectedRow.Cells(1).TextDim pnameAs New Parameter("name", TypeCode.String, name)Me.SqlDataSource1.UpdateParameters.Add(pname)Dim psplitAs New Parameter("split", TypeCode.String, Split)Me.SqlDataSource1.UpdateParameters.Add(psplit)Me.SqlDataSource1.Update()End Sub
I keep getting one of 2 errors they are
Object reference not set to an instance of an object. or
one that says i had to many aurgements
any idea what im doing wrong?
Change these lines
Dim nameAs String =Me.GridView1.SelectedRow.Cells(0).TextDim SplitAs String =Me.GridView1.SelectedRow.Cells(1).Text
to
Dim nameAs String = e.NewValues["name"].ToString();Dim SplitAs String = e.NewValues["split"].ToString();
I guess above changes can solve your proble.
|||
In addition topooya.m's answer, try putting a break point and debug through your code.
I tried that and getting this
Compiler Error Message:BC30203: Identifier expected.
Line 154:Me.SqlDataSource1.UpdateParameters.Clear()Line 155:Line 156:Dim nameAs String = e.NewValues["name"].ToString();Line 157:Dim SplitAs String = e.NewValues["split"].ToString();Line 158:
|||
Looks like u need to @.Name and @.split as the name of the parameters .. cause that whats ur sproc is expecting instead of Name and spilt|||
YahoosSnake:
Line 156: Dim nameAs String = e.NewValues["name"].ToString();
Line 157: Dim SplitAs String = e.NewValues["split"].ToString();
You're getting the compiler error because the above code is not valid code. You are combining VB and C# style syntax. Use
Dim name As String = e.NewValues("name").ToString()
Dim Split As String = e.NewValues("split").ToString()
DisturbedBuddha is right,
I used C# syntax to access NewValues. asDisturbedBuddha said you have to change NewValues["..."] to NewValues("...")
How do i set up the web.confgire to run the debuger thorw vb.net 2005 i put this in the file already
<compilation debug="true" />
but i get this error
Unable to start debugging on the web server. Logon Fauilure, unknow username or bad password.
Where do i setup the username and password for my sever on the web.config file?
sql
No comments:
Post a Comment