Hi,
I am create one application using C#.net and SQL Server 2005,
In this application uses procedure,plz give me syntax how to create procedure in SQL Server and how to handle error in stored procedure.
Sujit_Patil
0
Newbie Poster
Recommended Answers
Jump to PostUse this
SqlConnection myConnection = new SqlConnection("Data Source=IPaddress;Initial Catalog=databasename;Persist Security Info=True;User ID=username;Password=password"); SqlCommand cmd = new SqlCommand("SP name", myConnection); cmd.CommandType = CommandType.StoredProcedure; SqlParameter par = cmd.Parameters.Add("@MESSAGE ", SqlDbType.Varchar); par.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add("param", SqlDbType.NVarChar, 50).Value = "**"; myConnection.Open(); cmd.ExecuteNonQuery(); string strerrormes=par.Value;
Database side
IF @@ERROR <> 0
SET …
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.