日期:2014-05-17 浏览次数:20452 次
sql = string.Format(" insert into neirong(lindex,title,contents,creattime,readcount,Tag)values('{0}','{1}','{2}','{3}',{4},'{5}') ", lindex, title, contents, DateTime.Now.ToString("yyyy-MM-dd"), 0, tag); ret = ExcuteSQL(sql); return ret;[code=C#]
/C# string query = "Insert Into neirong(xx,xx) Values (?,?)"; string query2 = "Select @@Identity"; int ID; string connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|Northwind.mdb"; using (OleDbConnection conn = new OleDbConnection(connect)) { using (OleDbCommand cmd = new OleDbCommand(query, conn)) { cmd.Parameters.AddWithValue("", xxx.Text); cmd.Parameters.AddWithValue("", xxx.Text); conn.Open(); cmd.ExecuteNonQuery(); cmd.CommandText = query2; ID = (int)cmd.ExecuteScalar(); } }