使用此:使用SQL C#绑定结果准备语句
SqlConnection myConnection = new SqlConnection("Data Source=.\\SERVER;Initial Catalog=DB;Integrated Security=True;TrustServerCertificate=True;User Instance=False");
myConnection.Open();
SqlCommand myCommand = new SqlCommand("SELECT BusinessName FROM Businessess WHERE BusinessID = @Param2", myConnection);
SqlParameter myParam2 = new SqlParameter("@Param2", SqlDbType.Int, 4);
myParam2.Value = 1;
myCommand.Parameters.Add(myParam2);
MessageBox.Show(myCommand); //How do I bind results to show as string?
如何准备语句的结果绑定到一个变量,这样我可以操纵他们?
你为什么不使用存储过程? – 2012-02-11 15:19:44