我用的vs2010 C#语言,构建了个数据库是sql management,希望能做一个留言板出来。
stringstrconnection=@"provider=Micorosoft.jet.OleDb.4.0;DataSource=";strconnection+=S...
string strconnection = @"provider=Micorosoft.jet.OleDb.4.0;Data Source=";
strconnection += Server.MapPath(".\\App_Data\\MsgBoard.mdf");
DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory("System.Data.OleDb");
DbConnnction dbConnection = dbProviderFactory.CreateConnection();
dbConnection.ConnectionString = strconnection;
dbConnection.Open();
DbCommand dbCommand = dbProviderFactory.CreateCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandText = "INSERT INTO post(name,subject,message,[data],ip)VALUES("";dbCommand.CommandText+=strname+"",""+strsubject+"",""+strmsg+"",""+strdata+"",""+strip+"")";
dbCommand.ExecuteNonQuery();
dbConnection.Close();
dbConnection.Dispose();
Response.Redirect("default.aspx");
求大神看看这段代码,怎么改才是对的~~~如果知道可以发我邮箱2426839926@qq.com 展开
strconnection += Server.MapPath(".\\App_Data\\MsgBoard.mdf");
DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory("System.Data.OleDb");
DbConnnction dbConnection = dbProviderFactory.CreateConnection();
dbConnection.ConnectionString = strconnection;
dbConnection.Open();
DbCommand dbCommand = dbProviderFactory.CreateCommand();
dbCommand.Connection = dbConnection;
dbCommand.CommandText = "INSERT INTO post(name,subject,message,[data],ip)VALUES("";dbCommand.CommandText+=strname+"",""+strsubject+"",""+strmsg+"",""+strdata+"",""+strip+"")";
dbCommand.ExecuteNonQuery();
dbConnection.Close();
dbConnection.Dispose();
Response.Redirect("default.aspx");
求大神看看这段代码,怎么改才是对的~~~如果知道可以发我邮箱2426839926@qq.com 展开
3个回答
展开全部
string strconnection = @"provider=Micorosoft.jet.OleDb.4.0;Data Source=";
strconnection += Server.MapPath(".\\App_Data\\MsgBoard.mdf");
你这个是access 数据库的写法,你怎么用sql数据库呢
strconnection += Server.MapPath(".\\App_Data\\MsgBoard.mdf");
你这个是access 数据库的写法,你怎么用sql数据库呢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不懂英文,我都是用的e语言做的软件,不过只能自己用,不过杀毒软件,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询