Problem With Editing Datagrid...

  • Thread starter Paul B via .NET 247
  • Start date
P

Paul B via .NET 247

I keep getting the following error:
Specified argument was out of the range of valid values.Parameter name: value

It's cryptic to me as I'm new to .NET but "paramter name: value"There is no parameter named value! The error occurs here:


Line 131:
Line 132: Sub BindData()
Line 133:---> DataGrid1.DataBind()
Line 134: End Sub
Line 135:


' Code that calls BindData()

Public Sub DataGrid1_UpdateCommand(ByVal sender As Object, ByVale As DataGridCommandEventArgs)
If IsValid Then
'Dim intMlevel As Integer =CType(e.Item.FindControl("MLevel"),System.Web.UI.WebControls.DropDownList).SelectedValue
'SqlDataAdapter1.UpdateCommand.Parameters.Add("@m_level",intMlevel)
'SqlDataAdapter1.Update(UserDataSet1)
Call BindData()
DataGrid1.EditItemIndex = -1
Call BindData()
MessageBox.Text = "Record Has Been Updated."
Else
MessageBox.Text = "There Was an Error With Your Submission."
End If
End Sub

I have commented out the update command and still the error?
Here's the SqlUpdateCommand as created by VS.NET:

'
'SqlUpdateCommand1
'
Me.SqlUpdateCommand1.CommandText = "[UserUpdate]"
Me.SqlUpdateCommand1.CommandType =System.Data.CommandType.StoredProcedure
Me.SqlUpdateCommand1.Connection = Me.SqlConnection1
Me.SqlUpdateCommand1.Parameters.Add(NewSystem.Data.SqlClient.SqlParameter("@RETURN_VALUE",System.Data.SqlDbType.Int, 4,System.Data.ParameterDirection.ReturnValue, False, CType(0,Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current,Nothing))
Me.SqlUpdateCommand1.Parameters.Add(NewSystem.Data.SqlClient.SqlParameter("@user_id",System.Data.SqlDbType.Int, 4, "user_id"))
Me.SqlUpdateCommand1.Parameters.Add(NewSystem.Data.SqlClient.SqlParameter("@email_address",System.Data.SqlDbType.VarChar, 100, "email_address"))
Me.SqlUpdateCommand1.Parameters.Add(NewSystem.Data.SqlClient.SqlParameter("@pwd",System.Data.SqlDbType.VarChar, 16, "pwd"))
Me.SqlUpdateCommand1.Parameters.Add(NewSystem.Data.SqlClient.SqlParameter("@m_name",System.Data.SqlDbType.VarChar, 15, "m_name"))

The SPROC:

ALTER PROCEDURE alumni.UserUpdate
(
@user_id int,
@m_name char(15),
@pwd char(16),
@email_address char(100),
@m_level int
)
AS
SET NOCOUNT OFF;
UPDATE dbo.users SET email_address = @email_address, pwd = @pwd,m_level = @m_level, m_name = @m_name WHERE (user_id = @user_id);
SELECT user_id, email_address, pwd, m_level, m_name FROMdbo.users WHERE (user_id = @user_id)




I ALSO wanted to know, how do I get rid of the trailing spaces inmy database entries... I don't mind them being in the databasebut when editing they are a nuisance.

Your help is greatly appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top