Public void ABC ()
{
String A = textbox1.text. Trim () + "-" + textbox2.text. Trim () + "-" + textbox3.text. Trim () + "20:00:00 ";
String B = textbox4.text. Trim () + "-" + textbox5.text. Trim () + "-" + textbox6.text. Trim () + "20:00:00 ";
Try
{
If (datetime. parse (a)> datetime. parse (B ))
{
MessageBox. Show ("the start time must be earlier than the end time ");
Return;
}
Sqlconnection conn = new sqlconnection ("Server = 10.19.1.59; database = mete_data; uid = sa; Pwd = 123 ");
// Sqlconnection conn = new sqlconnection ("Server =.; database = mete_data; trusted_connection = yes ");
Conn. open ();
// Call the Stored Procedure
Sqlcommand comm = new sqlcommand ();
Comm. Connection = conn;
Comm. commandtext = "xcallstation_betweentwotime_sumrain"; // name of the stored procedure
Comm. commandtype = commandtype. storedprocedure;
Idataparameter [] parameters =
{
New sqlparameter ("@ strstartdatetime", sqldbtype. varchar, 30), // name of the parameter in the Stored Procedure
New sqlparameter ("@ strenddatetime", sqldbtype. varchar, 30) // name of the parameter in the Stored Procedure
};
// Parameters [0]. value = "2012-7-6 ";
// Parameters [1]. value = "2012-7-7 ";
Parameters [0]. value =;
Parameters [1]. value = B;
Comm. Parameters. Add (parameters [0]);
Comm. Parameters. Add (parameters [1]);
//// Directly Query
// Sqlcommand comm = new sqlcommand ("select * From rain_realtime", Conn );
Sqldataadapter SDA = new sqldataadapter ();
SDA. selectcommand = comm;
Dataset DS = new dataset ();
SDA. Fill (DS );
Datagridview1.datasource = Ds. Tables [0];
}
Catch (exception ex)
{
MessageBox. Show (ex. tostring ());
}
}