日期:2014-05-19  浏览次数:20988 次

哪位哥哥给小弟看看 数据库,添加 代码哪错了~ 小弟刚学的~请各位给看看~在线等
string   aa;
                aa   =   username.Text;
                 
                OleDbConnection       conn=new       OleDbConnection();      
    conn.ConnectionString= "provider=microsoft.jet.oledb.4.0; "+ "data       source= "+Server.MapPath( "App_Data/#13413.ldb ");      
    conn.Open();      
                string   Str   =   "insert   into   T_info2(F_title)   values( "this.username.Text; ") ";
                OleDbCommand   cmdadd   =   new   OleDbCommand(Str,   c.con);
                c.Open1();
                cmdadd.ExecuteNonQuery();
                c.Close1();
                Response.Write( " <script   language=javascript> alert( '添加完毕! ') </script> ");

------解决方案--------------------
string Str = "insert into T_info2(F_title) values( "+this.username.Text + ") ";

------解决方案--------------------
晕 c.Open1() 是个嘛玩意?
------解决方案--------------------
try
{
string connstr = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + @ "C:\db1.mdb "; OleDbConnection conn = new OleDbConnection(connstr);
string Str = "insert into T_info2(F_title) values( ' "+this.username.Text + " ') ";
OleDbCommand cmd = new OleDbCommand(Str,conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
------解决方案--------------------
try
{
string connstr = @ "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + @ "C:\db1.mdb "; OleDbConnection conn = new OleDbConnection(connstr);
string Str = "insert into T_info2(F_title) values( ' "+this.username.Text + " ') ";
conn.Open();
OleDbCommand cmd = new OleDbCommand(Str,conn);
cmd.ExecuteNonQuery();
conn.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}