当前位置:问百问>生活百科>c# Parameters.Add

c# Parameters.Add

2024-10-04 04:27:06 编辑:zane 浏览量:526

c# Parameters.Add

的有关信息介绍如下:

c# Parameters.Add

SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind"); SqlCommand salesCMD = new SqlCommand("SalesByCategory", nwindConn);salesCMD.CommandType = CommandType.StoredProcedure; SqlParameter myParm = salesCMD.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15);myParm.Value = "Beverages"; nwindConn.Open(); SqlDataReader myReader = salesCMD.ExecuteReader(); Console.WriteLine("{0}, {1}", myReader.GetName(0), myReader.GetName(1)); while (myReader.Read()){ Console.WriteLine("{0}, ${1}", myReader.GetString(0), myReader.GetDecimal(1));} myReader.Close();nwindConn.Close();

版权声明:文章由 问百问 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.wenbwen.com/life/172268.html
热门文章