I have the following code that derives the value from a query string -
// the code ->
protected void Page_Load(objec t sender, EventArgs e)
{
string theTime = Request.QuerySt ring["time"];
string altitude = Request.QuerySt ring["altitude"];
string latitude = Request.QuerySt ring["latitude"];
string longitude = Request.QuerySt ring["longitude"];
lblTtime.Text = theTime;
lblAltitude.Tex t = altitude;
lblLatitude.Tex t = latitude;
lblLongitude.Te xt = longitude;
if (theTime == "" || altitude == "" || latitude == "" || longitude == "")
{
// do nothing
}
else
{
string conn =
ConfigurationMa nager.AppSettin gs["ConnectionStri ng"].ToString();
// lblConn.Text = conn;
string selectSQL = "update gps_table set ";
selectSQL += "gps_time= @gps_time,";
selectSQL +="gps_altitu de = @gps_altitude," ;
selectSQL +="gps_latitu de = @gps_latitude," ;
selectSQL +="gps_longitud e = @gps_longitude where gps_id=1";
OleDbConnection MyConnection = new OleDbConnection (conn);
OleDbCommand MyCommand = new OleDbCommand(se lectSQL, MyConnection);
MyCommand.Param eters.Add(new OleDbParameter( "@gps_time" ,
Convert.ToDateT ime(theTime)));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_altitude" ,
Convert.ToDoubl e(altitude)));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_latitude" , latitude));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_longitude ", longitude));
MyConnection.Op en();
MyCommand.Execu teNonQuery();
}
I am getting the exception : Parameter @gps_latitude has no default value.
Why? How I can I solve this problem? Is this a VS2005 bug?
// the code ->
protected void Page_Load(objec t sender, EventArgs e)
{
string theTime = Request.QuerySt ring["time"];
string altitude = Request.QuerySt ring["altitude"];
string latitude = Request.QuerySt ring["latitude"];
string longitude = Request.QuerySt ring["longitude"];
lblTtime.Text = theTime;
lblAltitude.Tex t = altitude;
lblLatitude.Tex t = latitude;
lblLongitude.Te xt = longitude;
if (theTime == "" || altitude == "" || latitude == "" || longitude == "")
{
// do nothing
}
else
{
string conn =
ConfigurationMa nager.AppSettin gs["ConnectionStri ng"].ToString();
// lblConn.Text = conn;
string selectSQL = "update gps_table set ";
selectSQL += "gps_time= @gps_time,";
selectSQL +="gps_altitu de = @gps_altitude," ;
selectSQL +="gps_latitu de = @gps_latitude," ;
selectSQL +="gps_longitud e = @gps_longitude where gps_id=1";
OleDbConnection MyConnection = new OleDbConnection (conn);
OleDbCommand MyCommand = new OleDbCommand(se lectSQL, MyConnection);
MyCommand.Param eters.Add(new OleDbParameter( "@gps_time" ,
Convert.ToDateT ime(theTime)));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_altitude" ,
Convert.ToDoubl e(altitude)));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_latitude" , latitude));
MyCommand.Param eters.Add(new OleDbParameter( "@gps_longitude ", longitude));
MyConnection.Op en();
MyCommand.Execu teNonQuery();
}
I am getting the exception : Parameter @gps_latitude has no default value.
Why? How I can I solve this problem? Is this a VS2005 bug?
Comment