lost in Csharp.translation(again)

    Date: 12/07/07 (Web Development)    Keywords: database, sql

    How do I get a datareader to compare a number entered in a text box with the information in a database? I have the datareader connected, but I think the problem may lie in my SQL statement: here's the whole code:


    Session.Add("Quantity", txtQuantity.Text);
    //Adds the info in txtQuantity.Text to a session, for later use.
    //there is already an exception that checks if a user entered a number or letter
    //...no worries there.
    OleDbConnection conn = new
    OleDbConnection((string)Application["DBConnectionString"]);
    OleDbDataReader qdr = null;
    //the value of qdr is originally null, will get filled later.
    // Query string concatenates fixed text with the user's selection
    string qtyString = "SELECT Products.UnitsInStock " + "FROM Products " + "WHERE Products.UnitInStock ="; //+ //int.Parse(Session["Quantity"].ToString());
    // OleDbDataAdapter da = new OleDbDataAdapter();
    OleDbCommand cm = new OleDbCommand(qtyString, conn);
    conn.Open();
    qdr = cm.ExecuteReader();
    //Since I have a "where Products.UnitInstock =", I get an error that qdr is still null.
    /*I suspect my comparison would go somewhere here, but I am unsure how to write a comparison of a textbox value to qtyString (or if there is another better way of comparing the two. */
    qdr.Close();
    conn.Close();
    thanks :). PS formatting sucks cos I disabled the richtext editor.

    Source: http://community.livejournal.com/webdev/451053.html

« Can anyone recommend a good... || #region and #endregion... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home