My SQL SELECT Statement throws an exception on site but not locally

Discussion in 'Databases' started by mbscott, Feb 28, 2011.

  1. Here is the code that is throwing the exception:

    dbConn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source= E:/web/yourharv/testsite/Database/HarvestHouse.mdb; Persist Security Info=False");
    dbConn.Open();
    dbCmd = dbConn.CreateCommand();

    // Look for an existing record for this donor
    dbCmd.CommandText = "SELECT DonorID FROM donor WHERE CardName = \"" + Name.Text.Trim() + "\" AND Address = \"" + Addr.Text.Trim() + "\" AND Zip = \"" + Zip.Text.Trim() +"\"";
    dbReader = dbCmd.ExecuteReader();

    "E:/web/yourharv" iis the site root and the connection is successful. The problem is the select statements I use here do not work there. I get a "No value given..." exception thrown. The select statement is correct, by SQL standards, so I wonder it there is something I have missed in making my connection.

    Has anyone experienced this. I use these statements often and this is a new one on me.

    Thanks,

    Mike
     
  2. Ray

    Ray

    I don't think these values are being passed correctly.

    Name.Text.Trim()
    Addr.Text.Trim()
    Zip.Text.Trim()
    dbCmd.ExecuteReader()

    For now as a test try hard coding it.
     
  3. Thanks for taking and interext

    i the resultant string is correct:

    SELECT DonorID FROM donor WHERE CardName = "Michael Brucex Scott" AND Address = "2901 Travis Ave. Apt. 55" AND Zip = "76110"

    This is the actual string that throws the exception.

    This string works locally.
     
  4. I tried the hard code method

    I tried the hard code method and got the same result..
     
  5. FIQURED it out, another dumb programmer mistake. I was using a database in a test location and forgot to move it to the launch location.

    It is usually simple and the programmer's fault!!!!
     
  6. Glad you worked it out.
     

Share This Page