I am currently trying to grab some rows from a SQL Server database using C #, which have the following criteria:
- From the
RamResults - in the table
Results - where the
Date column is the current date
I have the following:
// Open the same connection with the same connection string. using (SqlCeConnection con = new SqlCeConnection(DatabaseControl.conString)) { con.Open(); // Read specific values in the table. using (SqlCeCommand com = new SqlCeCommand("SELECT Result FROM RamResults WHERE Date == @Form1.date", con)) { SqlCeDataReader reader = com.ExecuteReader(); while (reader.Read()) { int resultsoutput = reader.GetInt32(0); MessageBox.Show(resultsoutput.ToString()); } } }
Using SELECT Result FROM RamResults WHERE Date == Form1.date causes an error:
An error occurred while parsing the request. [Token line number = 1, token line offset = 43, token with error = =]
Although I take out the WHERE statement, for example.
SELECT Result FROM RamResults
it works great
source share