add new row to access

Discussion in 'ASP.NET / ASP.NET Core' started by steurm, Jun 22, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. NIT,

    You have to do at least 2 things:
    1. specify the commandtype : i.e. cmd.CommandType = CommandType.Text
    2. specify the parameters in your sql-string: i.e. "Parameters @password text,@username text,@name text,@mail text;Insert into tbl_users ..."
    I'm not sure if the @ is allowed for access, as it is necessary for SQL Server.

    Success


     
  2. q8z

    q8z

    this sql not work:
    private void addUser( )
    {
    try
    {
    this.openConnection();
    OleDbConnection Conn = new OleDbConnection();
    Conn.ConnectionString = this.con.ToString();
    string strAdd = "insert into tbl_users (password,userName,name,mail) values (@password,@userName,@name,@mail)";
    OleDbCommand cmd = new OleDbCommand();
    cmd.Parameters.Add("@password", OleDbType.VarWChar, 50, this.TxtPassword.Text);
    cmd.Parameters.Add("@userName", OleDbType.VarWChar, 50, TxtUserName.Text);
    cmd.Parameters.Add("@name", OleDbType.VarWChar, 50, TxtName.Text);
    cmd.Parameters.Add("@mail", OleDbType.VarWChar, 50, TxtMail.Text);
    cmd.CommandText = strAdd;
    cmd.Connection = Conn;
    cmd.ExecuteNonQuery();
    }
    catch (Exception ex)
    {
    LblError.Text=ex.ToString();
    }
    finally
    {
    this.closeConnection( );
    }
    }

    i get this error:
    System.ArgumentException: Format of the initialization
    string does not conform to the OLE DB specification.
    Starting around char[0] in the connection string. at
    System.Data.OleDb.OleDbConnection.ParseConnectionString(String&
    value, Boolean checkForUDL) at
    System.Data.OleDb.OleDbConnection.set_ConnectionString(String
    value) at Idea.regist.addUser() in
    c:\inetpub\wwwroot\idea\regist.aspx.cs:line 89

    thanks
     
  3.  
  4. Why am I still getting this error?
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page