I need to add an 'InsertCommand' to my query via sqldatasource, but i cannot see this option, i only have the 'order', 'where' and 'advanced' option, could you please advice?
Hi,
VB is great :) you can add and you insertcommand in code behind for example:
Private Sub Page_Load(ByVal sender As Object, ByVal e As eventArgs) Handles Page.Load
SqlDataSource1.InsertCommand.Add("Cell_Name", System.CodeType.String, TextBox.Text)
End Sub
Thats it
Hope it helps
------------------------------
Please do not forget to mark as "Answered" the answer which helped you. Thanks
|||It seems that you want to add an InsertCommand to your SQLDatasource dynamically. Below is the code you can use to create an insert command for an existing sql datasource.
<your sql datasource id>.InsertCommand = "<either your insert query or stored procedure name>"
<your sql datasource id>.InsertCommandType = SqlDataSourceCommandType.StoredProcedure or SqlDataSourceCommandType.Text
You can add the command parameters using <your sql datasource id>.InsertParameters.Add method.
To call the insert method you can to use <your sql datasource id>.Insert().
Hope this will help.
|||i have tried using this code but the 'SqlDataSource1' and 'System.CodeType' are not recognised; says its not declared.
could you please advice?
|||Hi,
did you added SqlDataSource control in your aspx page ?
Regards
|||Yes, and i used the same ID name.
No comments:
Post a Comment