[WebMethod(Description = "接收日志记录")]
public DataSet GetDataset(string SQL)
{
#region 将UserLog复制并改为带当前日期的MDB
string NowDate = DateTime.Now.ToString("yyyy-MM-dd");
string[] jie = NowDate.Split('-');
string sourceFile = AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\UserLog.mdb";
string targetFile = AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\UserLog" + jie[0] + jie[1] + jie[2] + ".mdb";
if (File.Exists(targetFile) == false)
{
File.Copy(sourceFile, targetFile);
}
#endregion
Connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+targetFile+";Persist Security Info=False";
OleDbConnection MyConn = new OleDbConnection(Connstr);
try
{
MyConn.Open();
OleDbDataAdapter MyCommand = new OleDbDataAdapter(SQL, MyConn);
OleDbCommand Mycmd = new OleDbCommand(SQL, MyConn);
Mycmd.ExecuteNonQuery();
DataSet ds = new DataSet();
MyCommand.Fill(ds);
MyConn.Close();
return ds;
}
catch (Exception ex)
{
throw ex;
}
}
以上webservice代码为何不能更新数据库?我用的是winform端调用的websevice,SQL的值为"insert into user_log(类型,用户名) values ('" + lx + "','" + yhm + "') ";
- 4 回答
- 0 关注
- 404 浏览
添加回答
举报
0/150
提交
取消