110,537
社区成员
发帖
与我相关
我的任务
分享
string connstr = "";
connstr = "数据库连接字符串";
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "create table t(a int)";
cmd.ExecuteNonQuery();
conn.Close();
String DBConnStr;
System.Data.SqlClient.SqlDataAdapter DataAdapter = new System.Data.SqlClient.SqlDataAdapter();
DBConnStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectString"];
System.Data.SqlClient.SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(DBConnStr);
if (myConnection.State != ConnectionState.Open)
{
myConnection.Open();
}
System.Data.SqlClient.SqlCommand myCommand = new System.Data.SqlClient.SqlCommand("create table t(a int)", myConnection);
myCommand.ExecuteNonQuery();