"c# execute transact sql" Code Answer's
You're definitely familiar with the best coding language SQL that developers use to develop their projects and they get all their queries like "c# execute transact sql" answered properly. Developers are finding an appropriate answer about c# execute transact sql related to the SQL coding language. By visiting this online portal developers get answers concerning SQL codes question like c# execute transact sql. Enter your desired code related query in the search bar and get every piece of information about SQL code related question on c# execute transact sql.
c# execute transact sql
static public int AddProductCategory(string newName, string connString)
{
Int32 newProdID = 0;
string sql =
"INSERT INTO Production.ProductCategory (Name) VALUES (@Name); "
+ "SELECT CAST(scope_identity() AS int)";
using (SqlConnection conn = new SqlConnection(connString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.Add("@Name", SqlDbType.VarChar);
cmd.Parameters["@Name"].Value = newName;
try
{
conn.Open();
newProdID = (Int32)cmd.ExecuteScalar();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
return (int)newProdID;
}
Source: stackoverflow.com
All those coders who are working on the SQL based application and are stuck on c# execute transact sql can get a collection of related answers to their query. Programmers need to enter their query on c# execute transact sql related to SQL code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# execute transact sql for the programmers working on SQL code while coding their module. Coders are also allowed to rectify already present answers of c# execute transact sql while working on the SQL language code. Developers can add up suggestions if they deem fit any other answer relating to "c# execute transact sql". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# execute transact sql resolved professionally and stay updated to the latest SQL updates.