I have a database with 4 columns HouseNo, Date, Time and IndoorTemp. In my C# Windows application I have 4 textboxes, one each for the above columns.
The user enters the HouseNo, Date and Time values in the Text Box. The inputs here should be a part of my SQL Where Clause with the output as the Indoor Temperature. This should then be displayed in the last text box.
I have used this connection:
// Create a String to hold the database connection string.
string sdwConnectionString = @"Data Source=IE1ADTBD5ZL1S\;Initial Catalog=ThermostatData2;Integrated Security=True";
// Create a connection
SqlConnection sdwDBConnection = new SqlConnection(sdwConnectionString);
I tried a code to do this but it failed. My code is,
cmd.IndoorTemp = "select * from ThermData where HouseNo = '" + HouseNovalue.Text + "' and Date = '" + Datevalue.Text + "' and Time = '" + Timevalue.Text + "' ";
How do i achieve the desired result.
I am new to C# and do not know much. All the above code was also with the help of a few blogs.
Do please help me out on this one. Also suggest a good book where i could learn to program C# with SQL Server. Thanks a lot in advance.