B
Benedictum
I have the following code that derives the value from a query string -
// the code ->
protected void Page_Load(object sender, EventArgs e)
{
string theTime = Request.QueryString["time"];
string altitude = Request.QueryString["altitude"];
string latitude = Request.QueryString["latitude"];
string longitude = Request.QueryString["longitude"];
lblTtime.Text = theTime;
lblAltitude.Text = altitude;
lblLatitude.Text = latitude;
lblLongitude.Text = longitude;
if (theTime == "" || altitude == "" || latitude == "" || longitude == "")
{
// do nothing
}
else
{
string conn =
ConfigurationManager.AppSettings["ConnectionString"].ToString();
// lblConn.Text = conn;
string selectSQL = "update gps_table set ";
selectSQL += "gps_time= @gps_time,";
selectSQL +="gps_altitude = @gps_altitude,";
selectSQL +="gps_latitude = @gps_latitude,";
selectSQL +="gps_longitude = @gps_longitude where gps_id=1";
OleDbConnection MyConnection = new OleDbConnection(conn);
OleDbCommand MyCommand = new OleDbCommand(selectSQL, MyConnection);
MyCommand.Parameters.Add(new OleDbParameter("@gps_time",
Convert.ToDateTime(theTime)));
MyCommand.Parameters.Add(new OleDbParameter("@gps_altitude",
Convert.ToDouble(altitude)));
MyCommand.Parameters.Add(new OleDbParameter("@gps_latitude", latitude));
MyCommand.Parameters.Add(new OleDbParameter("@gps_longitude", longitude));
MyConnection.Open();
MyCommand.ExecuteNonQuery();
}
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(object sender, EventArgs e)
{
string theTime = Request.QueryString["time"];
string altitude = Request.QueryString["altitude"];
string latitude = Request.QueryString["latitude"];
string longitude = Request.QueryString["longitude"];
lblTtime.Text = theTime;
lblAltitude.Text = altitude;
lblLatitude.Text = latitude;
lblLongitude.Text = longitude;
if (theTime == "" || altitude == "" || latitude == "" || longitude == "")
{
// do nothing
}
else
{
string conn =
ConfigurationManager.AppSettings["ConnectionString"].ToString();
// lblConn.Text = conn;
string selectSQL = "update gps_table set ";
selectSQL += "gps_time= @gps_time,";
selectSQL +="gps_altitude = @gps_altitude,";
selectSQL +="gps_latitude = @gps_latitude,";
selectSQL +="gps_longitude = @gps_longitude where gps_id=1";
OleDbConnection MyConnection = new OleDbConnection(conn);
OleDbCommand MyCommand = new OleDbCommand(selectSQL, MyConnection);
MyCommand.Parameters.Add(new OleDbParameter("@gps_time",
Convert.ToDateTime(theTime)));
MyCommand.Parameters.Add(new OleDbParameter("@gps_altitude",
Convert.ToDouble(altitude)));
MyCommand.Parameters.Add(new OleDbParameter("@gps_latitude", latitude));
MyCommand.Parameters.Add(new OleDbParameter("@gps_longitude", longitude));
MyConnection.Open();
MyCommand.ExecuteNonQuery();
}
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?