Trouble with an SQL statement...maybe syntax related?
-
Hello, I have a c# code file and within it I have the following code: private void Page_Load(object sender, System.EventArgs e) { DBReader("SELECT PackageNumber FROM Packages WHERE Packages.PackageID = Level1Packages.PackageID"); } private void DBReader(string SQLQuery) { if(!IsPostBack) { OleDbCommand myCommand = new OleDbCommand(SQLQuery,oleDbConnection1); oleDbConnection1.Open(); dataReader = myCommand.ExecuteReader(); ******* while(dataReader.Read()) { this.Lvl1PackageNumListBox.Items.Add(dataReader.GetString(0)); } oleDbConnection1.Close(); } } The code dies on the line with stars with the error message "no value given for one or more parameters". I think the problem lies in my SQl statement I am passing to the DBReader method. I am not sure if using the . operator is correct when trying to access a column of a table. Thanks for helping out a newbie! Frank
-
Hello, I have a c# code file and within it I have the following code: private void Page_Load(object sender, System.EventArgs e) { DBReader("SELECT PackageNumber FROM Packages WHERE Packages.PackageID = Level1Packages.PackageID"); } private void DBReader(string SQLQuery) { if(!IsPostBack) { OleDbCommand myCommand = new OleDbCommand(SQLQuery,oleDbConnection1); oleDbConnection1.Open(); dataReader = myCommand.ExecuteReader(); ******* while(dataReader.Read()) { this.Lvl1PackageNumListBox.Items.Add(dataReader.GetString(0)); } oleDbConnection1.Close(); } } The code dies on the line with stars with the error message "no value given for one or more parameters". I think the problem lies in my SQl statement I am passing to the DBReader method. I am not sure if using the . operator is correct when trying to access a column of a table. Thanks for helping out a newbie! Frank
Going out on a limb here, but change the SQL to be
SELECT PackageNumber FROM Packages**,Level1Packages** WHERE Packages.PackageID = Level1Packages.PackageID,
Chris Meech It's much easier to get rich telling people what they want to hear. Chistopher Duncan I can't help getting older, but I refuse to grow up. Roger Wright I've been meaning to change my sig. Thanks! Alvaro Mendez We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton