473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Parameter Problem in OleDB

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?
Sep 30 '08 #1
2 2104

"Benedictum" <Be********@dominusvobis.comwrote in message
news:el**************@TK2MSFTNGP05.phx.gbl...
>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?
No, it's not a bug. I don't use OleDb. I use SQL Command Objects myself,
which would be using a T-SQL Update statement. However, it must be that
ADO.Net and Oledb are looking at the Parm.Add for "@gps_latitude", latitude
and latitude is null or something and maybe another "," needs to be in the
statement to indicate what default value should be given if latitude is null
data.

You can approach it at that angle. You should find out what is in latitude
and find out how to give a default value if Oledb determines that it needs a
default value applied to make the statement successful.
Oct 5 '08 #2
OLEDb uses positional parameters marked by ?, not @.

See
<http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbparameter.aspx>
On Mon, 29 Sep 2008 20:43:24 -0500, "Benedictum"
<Be********@dominusvobis.comwrote:
>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?
Oct 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: N S S | last post by:
I Get the following Error ================ Error =============================== Procedure 'GetCetgoriesOrProducts' expects parameter '@CategoryID', which was not supplied. Description: An...
0
by: silesius | last post by:
I've been using VS 2003 to develop a webapplication using C#. Today I exported the application to a remote webserver I begun experiencing problems. It's a simple application that retrieves some...
0
by: Manuel Arroba | last post by:
asp.net oledb command parameter error calling an as400 program Hi... I have an as400 program that I can call it directly and it works: variable= "xxxx" sql = "CALL METSIGOP.SIGOPRC ('" +...
0
by: silesius | last post by:
I've been using VS.NET 2003 to develop a webapplication using C#. Today I exported the application to another webserver I begun experiencing problems. It's a simple application that retrieves...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
1
by: Damon | last post by:
I've distilled this down into the simplest possible code fragment and this still doesn't make any sense. I'm trying to run a select query on an access database, and the query has NO parameters. ...
0
by: André | last post by:
Hi, I made a detailsview for inserting data in the table. I also made a dropdownlist which the selected value must be used for one of the field in the detailsview. In the <InsertParameters>...
11
by: pamelafluente | last post by:
Hi I am executing some simple sample code: Using OleDbCommand As New OleDbCommand(Me.DBQuery.Text, Me.OleDbConnection) Dim OleDbParameter As OleDbParameter =...
14
by: bill | last post by:
Can someone please show me an example of passing a string value into an sql statement in vb 2005? Something like this is what I'm after: Dim sqlButton1 As String = "Select * from tblAssets where...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.