473,785 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parameter Problem in OleDB

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

"Benedictum " <Be********@dom inusvobis.comwr ote in message
news:el******** ******@TK2MSFTN GP05.phx.gbl...
>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?
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.ole db.oledbparamet er.aspx>
On Mon, 29 Sep 2008 20:43:24 -0500, "Benedictum "
<Be********@dom inusvobis.comwr ote:
>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.Tex t = theTime;

lblAltitude.Te xt = altitude;

lblLatitude.Te xt = latitude;

lblLongitude.T ext = longitude;

if (theTime == "" || altitude == "" || latitude == "" || longitude == "")

{

// do nothing

}

else

{

string conn =
ConfigurationM anager.AppSetti ngs["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";

OleDbConnectio n MyConnection = new OleDbConnection (conn);

OleDbCommand MyCommand = new OleDbCommand(se lectSQL, MyConnection);

MyCommand.Para meters.Add(new OleDbParameter( "@gps_time" ,
Convert.ToDate Time(theTime))) ;

MyCommand.Para meters.Add(new OleDbParameter( "@gps_altitude" ,
Convert.ToDoub le(altitude)));

MyCommand.Para meters.Add(new OleDbParameter( "@gps_latitude" , latitude));

MyCommand.Para meters.Add(new OleDbParameter( "@gps_longitude ", longitude));

MyConnection.O pen();

MyCommand.Exec uteNonQuery();

}

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
1780
by: N S S | last post by:
I Get the following Error ================ Error =============================== Procedure 'GetCetgoriesOrProducts' expects parameter '@CategoryID', which was not supplied. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Procedure...
0
5292
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 information from an Access database. It worked fine when I ran on my computer. I use a parameterized query to retrieve some customer specific information. Customer logs in, I store the username they log in with in the session state and on the...
0
1453
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 ('" + variable + "')" Dim con As OleDbConnection Dim cmd As OleDbCommand con = New OleDbConnection()
0
2783
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 some information from an Access database. It worked fine when I ran on my home computer. I use a datagrid witha a dataset and a parameterized query to retrieve some customer specific information. Customer logs in, I store the username they log in...
7
3045
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 = ?) ORDER BY age " this.oleDbSelectCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("has_picture", System.Data.OleDb.OleDbType.Boolean, 1, "has_picture")); this.oleDbSelectCommand1.Parameters.Add(new...
1
1636
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. And yet, I'm still getting a "No value given for one or more required parameters" error. What gives? Here's my code. I put it in a Form_Load subroutine of a blank .aspx page so that nothing else external would affect it. (And yes, the Access...
0
869
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> tag, i removed the parameter 'lo' because i added it from code-behind. I put the 'DataKeyNames' as the primary key of the table in detailsview. My problem is:
11
4339
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 = OleDbCommand.Parameters.Add("@Pinco", OleDbType.VarWChar) OleDbParameter.Direction = ParameterDirection.Input OleDbParameter.Value = "Berlin"
14
1884
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 Asset_Tag = Me.cboAsset.Text" Thank you, Bill
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.