VS.NET C#
我用VS.NET C#开发的一个学籍管理系统,程序设计时候,怎么不能更新数据库里面的内容啊?SQL2005 --------------------编程问答-------------------- 具体代码? --------------------编程问答-------------------- 我是新手怎么把所有的代码都弄上来啊--------------------编程问答-------------------- 你怎么更新的数据库呢?把代码贴上来 --------------------编程问答-------------------- namespace WinAppDemo
{
class OperateDB
{
private static string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\testDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
public static string ConnString
{
get
{
return connString;
}
}
private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, CommandType cmdType, string cmdText)
{
if (conn.State!= ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandText = cmdText;
cmd.CommandType = cmdType;
}
public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText)
{
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(connectionString))
{
PrepareCommand(cmd, conn, cmdType, cmdText);
int val = cmd.ExecuteNonQuery();
return val;
}
}
public static DataSet ExecuteDataset(string connectionString, CommandType cmdType, string cmdText)
{
//Create a command and preaare it for execution
SqlCommand cmd = new SqlCommand();
using (SqlConnection conn = new SqlConnection(connectionString))
{
PrepareCommand(cmd, conn, cmdType, cmdText);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
//Return the dataset
return ds;
}
}
}
}
--------------------编程问答-------------------- 呵呵 --------------------编程问答-------------------- 刚注册的还不知道怎么用CSDN呢
补充:.NET技术 , C#