protected void btnsign_Click(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = true;
        OleDbCommand cmd1;
        OleDbDataReader reader1;
        OleDbConnection myconnection1;
        string connStr1 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\0606010020胡维燕\ASP.NET\lab06\App_Data\Users.mdb;Persist Security Info=True";
        myconnection1 = new OleDbConnection(connStr1);
        myconnection1.Open();
        cmd1 = new OleDbCommand(connStr1,myconnection1);
        //reader1 = cmd1.ExecuteReader();
        string strsql1 = @"INSERT INTO Users (U_name, U_pass, U_job,U_id,U_birth,U_email,U_hobby,U_sign) VALUES(" + txtname.Text + ",'" + txtpass1.Text + "','" + ddljob.SelectedValue + "','" + txtid.Text + "','" + ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlDay.SelectedValue + "','" + txtemail.Text + "','" + cblhobby.SelectedValue + "','" + txtsign.Text + "') ";
        cmd1 = new OleDbCommand(strsql1, myconnection1);
        //SqlCommand dbCmd2 = new SqlCommand(strSql2, dbConn2);
        OleDbDataAdapter dap = new OleDbDataAdapter(cmd1);
        DataSet dst = new DataSet("Users");
        dap.Fill(dst, "Users");
        //cmd1.CommandText =strsql1 ;
        //cmd1.CommandType = CommandType.Text;
        //cmd1.ExecuteNonQuery();
       
        myconnection1.Close();    }
==============================================================================================================================
错误提示:至少一个参数没有被指定值。
行 133:        OleDbDataAdapter dap = new OleDbDataAdapter(cmd1);
行 134:        DataSet dst = new DataSet("Users");
行 135:        dap.Fill(dst, "Users");
行 136:        //cmd1.CommandText =strsql1 ;
行 137:        //cmd1.CommandType = CommandType.Text;

解决方案 »

  1.   

    string strsql1 = @"INSERT INTO Users (U_name, U_pass, U_job,U_id,U_birth,U_email,U_hobby,U_sign) VALUES(" + txtname.Text + "," + txtpass1.Text + "," + ddljob.SelectedValue + "," + txtid.Text + "," + ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlDay.SelectedValue + "," + txtemail.Text + "," + cblhobby.SelectedValue + "," + txtsign.Text + ") "; 
    试一下这个
      

  2.   

    语法错误 (操作符丢失) 在查询表达式 '[email protected]' 中。 行 133:        OleDbDataAdapter dap = new OleDbDataAdapter(cmd1);
    行 134:        DataTable dt = new DataTable();
    行 135:        dap.Fill(dt);行 136:        //cmd1.CommandText = strsql1;
    行 137:        //cmd1.CommandType = CommandType.Text;还是错啊。
      

  3.   

    string strInsert = "Insert Into yqlj (y_name,y_wz,px) Values (@T1,@T2,@T3)";
    SqlCommand cmdInsert = new SqlCommand( strInsert, MyConnection2 );
    cmdInsert.Parameters.Add(new SqlParameter("@T1", 1150));
    cmdInsert.Parameters["@T1"].Value =TextBox1.Text;
    cmdInsert.Parameters.Add(new SqlParameter("@T2", 1150));
    cmdInsert.Parameters["@T2"].Value =TextBox2.Text;
    cmdInsert.Parameters.Add(new SqlParameter("@T3", 1150));
    cmdInsert.Parameters["@T3"].Value =TextBox3.Text;
    MyConnection2.Open();
    cmdInsert.ExecuteNonQuery();
    MyConnection2.Close();
    ====================================
    我用的是这种,你把改成这种试试,说实在的你的代码不直观。
      

  4.   

    thank you!
    万分感谢!
      

  5.   

    '" + ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlDay.SelectedValue + "'楼主你给上面的弄个变量string str=ddlYear.SelectedValue + ddlMonth.SelectedValue + ddlDay.SelectedValue '"+str+"'试试