我想知道如何一次执行多个 SQL 命令。
此刻我正在这样做:
using (SqlConnection sqlConnection1 = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "SELECT nome FROM teste";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
// execute the command
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
listBox1.Items.Add(rdr["name"].ToString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是我该怎么做才能执行
use [databaseX]
SELECT nome FROM teste
Run Code Online (Sandbox Code Playgroud)
在我的 C# 程序中?