Last post Dec 22, 2014 05:06 AM by Siva Krishna Macha
Dec 19, 2014 09:51 PM|edcal|LINK
I get message: AddWithValue is not a member of System.Data.SqlClient.SqlDataAdapter
SampleDataAdapter as new SqlDataAdapter(selectqry,connectionstring)
ymon) <======== ERROR MESSAGE AddWithValue is not a member of System.Data.SqlClient.SqlDataAdapter
What must I do to use the addwithvalue statement?
Dec 19, 2014 11:43 PM|Webblogsforyou2013|LINK
you need to use SqlCommand instead SqlDataAdapter, like this way:
Protected Sub gvSubDetails_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If e.CommandName = "Add" Then
Dim IsAdded As Boolean = False
Dim SubjectName As TextBox = CType(gvSubDetails.FooterRow.FindControl("newSubjectName"), TextBox)
Dim Marks As TextBox = CType(gvSubDetails.FooterRow.FindControl("newMarks"), TextBox)
Dim Grade As TextBox = CType(gvSubDetails.FooterRow.FindControl("newGrade"), TextBox)
Using sqlCon As New SqlConnection(conn)
Using cmd As New SqlCommand()
cmd.CommandText = "INSERT INTO SubjectDetails(SubjectName,Marks,Grade) VALUES(@SubjectName,@Marks,@Grade)"
cmd.Connection = sqlCon
IsAdded = cmd.ExecuteNonQuery() > 0
If IsAdded Then
lblMsg.Text = "'" & SubjectName.Text & "' subject details has been added successfully!"
lblMsg.ForeColor = System.Drawing.Color.Green
lblMsg.Text = "Error while adding '" & SubjectName.Text & "' subject details"
lblMsg.ForeColor = System.Drawing.Color.Red
For more details, check simple
Gridview Inline Insert Update and Delete Data in Asp.net here
Dec 20, 2014 08:25 AM|oned_gk|LINK
Dec 20, 2014 09:45 PM|edcal|LINK
Oned_gk, thanks for the code you sent. I do not understand the statement
BINDSUBJECTDATA(). Is this a keyword that I am supposed to define in my VB code. I need help on the statement BINDSUBJECTDATA().
Where is this being binded to?
Dec 22, 2014 05:06 AM|Siva Krishna Macha|LINK
I believe, BindSubjectData() is not a keyword. However, you would need to basically bind your GridView to some datasource (which you get from DB) and execute DataBind() at this stage.
GridView1.DataSource = <<some suitable object here >> 'Where GridView1 can be your gridview's id
As you would execute these two statements along with select query to DB, more frequently, you would have some private method (function) with in the page which you can call.