关于C#存储当前时间的问题
小弟初学C#,准备做一个仓库管理系统,在借出物品是自动添加系统当前时间却报错
代码如下: if (ID.Text == "" ||
Pname.Text == "" || Wname.Text == "" || Yongtu.Text == "")
MessageBox.Show("请输入数据,进行添加");
DateTime now = DateTime.Now;
String str = "Data Source=.;Initial Catalog=test;User ID=zwc;Password=hbhhzhen;connect Timeout=30";
SqlConnection conn = new SqlConnection(str);
if (ConnectionState.Closed == conn.State)
{
conn.Open();
}
SqlDataAdapter d = new SqlDataAdapter();
d.InsertCommand = new SqlCommand("INSERT INTO In(Inpeople,Intime,Yongtu,ID,Name)Values('" + Pname.Text + "',+'" + DateTime.Now + "','" + Yongtu.Text + "','" + ID.Text + "','" + Wname.Text + "')", conn);
d.InsertCommand.ExecuteNonQuery();
conn.Close();
ID.Clear(); ;
Pname.Clear(); ;
Wname.Clear();
Yongtu.Clear();
MessageBox.Show("添加成功");
提示In附近有语法错误,但是小弟我怎么看都没什么问题啊
这是什么原因啊,多谢了