Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2005
    Posts
    4

    Exclamation Unanswered: parameterised query c# oracle 8i

    I want to do a parameterised query using c# and oracle 8i, i dont want to use stored proedures,,, is there anything wrong with this code, or does anyone know any good websites that explains parameterised queries for
    oracle8i, there are loads for sql server but i'm not able to use that...

    the code below will not run, the page takes ages to load


    string objConn = "Provider = MSDAORA;User ID=103109798;Password=password;Data Source=orabis;";
    OleDbConnection myConnection = new OleDbConnection(objConn);
    string commandString = "INSERT INTO users(username,password)VALUES(:username,assword)";
    OleDbCommand myCommand = new OleDbCommand(commandString, myConnection);
    myCommand.Parameters.Add(":username", txtUsername.Text)
    myCommand.Parameters.Add("assword", txtPassword.Text)
    myConnection.Open();
    myCommand.ExecuteNonQuery();
    myConnection.Close();
    Last edited by ace999; 01-05-05 at 14:47.

  2. #2
    Join Date
    Mar 2004
    Location
    Warsaw / Poland
    Posts
    73
    Maybe
    Code:
    string objConn = "Provider = MSDAORA;User ID=103109798;Password=password;Data Source=orabis;"; 
    string user = txtUsername.Text;
    string pass = txtPassword.Text;
    
    OleDbConnection myConnection = new OleDbConnection(objConn);
    string commandString = "INSERT INTO users(username, password) VALUES(?, ?)"; 
    OleDbCommand myCommand = new OleDbCommand(commandString, myConnection);
    myCommand.Parameters.Add(user);
    myCommand.Parameters.Add(pass);
    myConnection.Open();
    myCommand.ExecuteNonQuery(); 
    myConnection.Close();
    will work?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •