• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 356
  • Last Modified:

Code Behind Syntax when using a Stored Procedure

In the following code behind what is the difference in the syntax if using a stored procedure.

Protected Sub InsertShipper (ByVal Source As Object, ByVal e As EventArgs)
  SqlDataSource1.Insert()
End Sub

The code above uses a T-SQL insert statement on an aspx page to insert a record into the database when button is clicked. I do know that the SelectCommandType on the aspx page will = Stored Procedure. However, I know the Insert of the ****SqlDataSource1.Insert()*** above will be different but I do not know the exact code that would be needed to fire the Stored Procedure and perform the insert.. Any help or guidance is greatly appreciated.
0
derrekdeveloper
Asked:
derrekdeveloper
  • 3
1 Solution
 
SriVaddadiCommented:
//

set connection string for SQLDataSource
///
mySqlDataSource.ConnectionString =

"< your connection string > ";
/// Specify select commands type and select command
///
mySqlDataSource.SelectCommandType =

SqlDataSourceCommandType.StoredProcedure;
mySqlDataSource.SelectCommand =

" myStoredProcedure";
/// specify some parameters for stored procedure
///
/// Parameter name direction : input
///
mySqlDataSource.SelectParameters.Add(

"@Name", TypeCode.String, "Name");
mySqlDataSource.SelectParameters[0].Direction =

ParameterDirection.Input;
/// Parameter name age : ouput
///
mySqlDataSource.SelectParameters.Add(

"@Name", TypeCode.Int16, "Name");
mySqlDataSource.SelectParameters[0].Direction =

ParameterDirection.Output;
/// its all set you can now use this is a DataSource for your controls
0
 
SriVaddadiCommented:
check this out even this might hlp

http://aspnet.4guysfromrolla.com/articles/030106-1.aspx
0
 
derrekdeveloperAuthor Commented:
Very, very good article offered.
0
 
SriVaddadiCommented:
Thanks appreciate  your comments
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now