Only think I am doing differently on the INSERT statement from the link above is that my table has an identify seed which automatically inserts the requesttypeID while the sample page inserts all records including the CustomerID.
Can someone please tell me what I am doing wrong?
Thanks a lot in advance
Protected Sub AddNewRequestType(ByVal sender As Object, ByVal e As EventArgs)
Dim RequestType As String = DirectCast(GridView1 _
.FooterRow.FindControl("txtrequestType"), TextBox).Text
Dim emailAdd As String = DirectCast(GridView1 _
.FooterRow.FindControl("txtEmailAdd"), TextBox).Text
Dim con As New SqlConnection(strConnString)
Dim cmd As New SqlCommand()
cmd.CommandType = CommandType.Text
cmd.CommandText = "insert into requestTypes(Type_of_Request,senders_Email values(@requestType, @emailAdd);" & _
"select Type_of_Request, Senders_email from requestTypes"
cmd.Parameters.Add("@requestType", SqlDbType.VarChar).Value = RequestType
cmd.Parameters.Add("@emailAdd", SqlDbType.VarChar).Value = emailAdd
GridView1.DataSource = GetData(cmd)
GridView1.DataBind()
End Sub
Member
255 Points
1159 Posts
Insert statement not inserting - frustrating
Feb 04, 2017 04:09 AM|simflex|LINK
Please forgive me for bordering you again.
I am using gridview to insert, delete, update and display records.
All but the insert statement works.
when I click to insert, nothing happens, no records are being inserted.
I followed the example from the following link:
http://www.aspsnippets.com/Articles/GridView---Add-Edit-Update-Delete-and-Paging-the-AJAX-way.aspx
Only think I am doing differently on the INSERT statement from the link above is that my table has an identify seed which automatically inserts the requesttypeID while the sample page inserts all records including the CustomerID.
Can someone please tell me what I am doing wrong?
Thanks a lot in advance
All-Star
31362 Points
7055 Posts
Re: Insert statement not inserting - frustrating
Feb 04, 2017 04:38 AM|kaushalparik27|LINK
On a quick look, there is issue with Insert statement that the small bracket is not closed.
insert into requestTypes(Type_of_Request,senders_Email) values(@requestType, @emailAdd);" & _ "select Type_of_Request, Senders_email from requestTypes.
Also, I suggest you transfer the query to Stored Procedure and use it instead of writing inline query.
hope that helps./.
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
255 Points
1159 Posts
Re: Insert statement not inserting - frustrating
Feb 04, 2017 12:31 PM|simflex|LINK
Great eyes!!!!!!
WOW, I have been staring at that screen for what seems like forever and could not spot it.
Thank you so much