在线给分--数据库小问题 如果要往数据库中插入一条记录(比如:"2005-05-21 7:09:34","关闭")如何做比较简单? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如何做都不是很难。SqlConnection connection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["db"]); SqlCommand command=new SqlCommand(); command.Connection=connection; command.CommandText="insert into table1(element1, element2) values('"+flag1+"','"+ flag2+"')"; connection.Open(); command.ExecuteNonQuery(); connection.Close(); command.Dispose(); 我在Time字段中要插入当前时间,但写成command.CommandText = "INSERT INTO Log ([Time],Description) VALUES(strDT,'ddd')";后是不能执行的,其中strDT是时间变量,我用的是access数据库,这个问题怎么解决? 某个windows服务的控制权限能否指定到某用户? 数据库 关于C# DataSet 填充数据问题 winform 下datagrid 禁止鼠标滚动 请问下,插件与模块(类库)有什么区别吗? 如何在C#中实现用上下键选择自己做的菜单 C# 怎么把EXCEl 2010默认的网格线隐藏掉!! wifnrom 的 控件 treeView1 服务器和本地同步 C#控件生成Release的版本的dll,怎么做? DATAgridview怎么在一列中加入 listbox! SqlCommandBuilder生成的SqlCommand对象能否自动处理%_'这样的特殊字符?
SqlConnection connection=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["db"]);
SqlCommand command=new SqlCommand();
command.Connection=connection;
command.CommandText="insert into table1(element1, element2) values('"+flag1+"','"+ flag2+"')";
connection.Open();
command.ExecuteNonQuery();
connection.Close();
command.Dispose();
command.CommandText = "INSERT INTO Log ([Time],Description) VALUES(strDT,'ddd')";
后是不能执行的,其中strDT是时间变量,我用的是access数据库,这个问题怎么解决?