sql="select * from article where (articleid is null)"
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("dateandtime")=date()
rs.update
articleid=rs("articleid")
rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("dateandtime")=date()
rs.update
articleid=rs("articleid")
command.CommandType = CommandType.StoredProcedure;command.CommandText = "insert into article (title,content,dateandtime,articleid) value (@title,@content,@dateandtime,@articleid)";
command.Parameters.Add(new SqlParameter("@title", title));
command.Parameters.Add(new SqlParameter("@content", content));
command.Parameters.Add(new SqlParameter("@dateandtime", dateandtime));
command.Parameters.Add(new SqlParameter("@articleid", articleid));
using (SqlConnection connection = new SqlConnection(_Connection))
{
command.Connection = connection;
connection.Open();
command.ExecuteNonQuery();
}
{
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure; command.CommandText = "insert into article (title,content,dateandtime,articleid) value (@title,@content,@dateandtime,@articleid)";
command.Parameters.Add(new SqlParameter("@title", title));
command.Parameters.Add(new SqlParameter("@content", content));
command.Parameters.Add(new SqlParameter("@dateandtime", dateandtime));
command.Parameters.Add(new SqlParameter("@articleid", articleid));
using (SqlConnection connection = new SqlConnection("Data Source=localhost;Initial Catalog=DatabaseName;Integrated Security=True"))
{
command.Connection = connection;
connection.Open();
command.ExecuteNonQuery();
}
}
这个在ACCESS中能实现吗
取得Access中自动生成的ID的SQL 语句:Select articleid from article order by articleid desc
如果非要返回ID的话,建议不要使用自动编号,改用SQL Server的GUID,可以在添加之前生成GUID,
但是我看到动网的数据库他们的表也是分开的,不知道他们是怎么写的