I'm stumped at this point and I'm tired of trying things so I'mposting in hopes of some guru with a sharp eye. I have anasp.net app running on a local Win XP Pro box. Within the app,I call a SPROC and pass the info to the SQL box and it hiccups. I'll drop VS.NET into debug mode and step through the SPROCcreation and copy those values into Query Analyzer to get alittle more info. When I run the Query Analyer that data worksjust fine. What?! Here is the relevant info:
------ASP.NET CODE---------------------
Dim parameterCustID As SqlParameter = NewSqlParameter ("@customerI D", SqlDbType.Int, 4)
parameterCustID .Value = customerID
orderCommand.Pa rameters.Add(pa rameterCustID)
Dim parameterDateOr dered As SqlParameter = NewSqlParameter ("@dateOrdered" , SqlDbType.DateT ime, 8)
parameterDateOr dered.Value = Today
orderCommand.Pa rameters.Add(pa rameterDateOrde red)
Dim parameterProduc tOrdered As SqlParameter = NewSqlParameter ("@productOrder ed", SqlDbType.VarCh ar, 50)
parameterProduc tOrdered.Value = productOrdered
orderCommand.Pa rameters.Add(pa rameterProductO rdered)
Dim parameterQuanti ty As SqlParameter = NewSqlParameter ("@quantity" , SqlDbType.Small Int, 2)
parameterQuanti ty.Value = CInt(quantity)
orderCommand.Pa rameters.Add(pa rameterQuantity )
Dim parameterCost As SqlParameter = New SqlParameter("@ cost",SqlDbType .SmallMoney, 4)
parameterCost.V alue = price
orderCommand.Pa rameters.Add(pa rameterCost)
Dim parameterCommen ts As SqlParameter = NewSqlParameter ("@comments" , SqlDbType.NVarC har, 255)
parameterCommen ts.Value = Trim(txtComment s.Text)
orderCommand.Pa rameters.Add(pa rameterComments )
Dim parameterCCNum As SqlParameter = New SqlParameter("@ CCNum",SqlDbTyp e.VarChar, 50)
parameterCCNum. Value = Trim(txtCardNum ber.Text)
orderCommand.Pa rameters.Add(pa rameterCCNum)
Dim parameterExpDat e As SqlParameter = NewSqlParameter ("@ExpDate", SqlDbType.VarCh ar, 50)
parameterExpDat e.Value = expDate
orderCommand.Pa rameters.Add(pa rameterExpDate)
Dim parameterCCV As SqlParameter = New SqlParameter("@ CCV",SqlDbType. VarChar, 3)
parameterCCV.Va lue = Trim(Issue.Text )
orderCommand.Pa rameters.Add(pa rameterCCV)
Dim parameterorderI D As SqlParameter = NewSqlParameter ("@orderID", SqlDbType.Int, 4)
parameterorderI D.Direction = ParameterDirect ion.Output
orderCommand.Pa rameters.Add(pa rameterorderID)
orderCommand.Ex ecuteNonQuery()
' Return the OrderID
Dim orderID As Integer = parameterCustom erID.Value
--------------------------
-------SPROC in SQL 2K-------------------
CREATE Procedure addOrder
(
@customerID int,
@dateOrdered datetime,
@productOrdered varchar(50),
@quantity smallint,
@cost smallmoney,
@comments nvarchar(255),
@CCNum varchar(50),
@ExpDate varchar(50),
@CCV varchar(3),
@OrderID int OUTPUT
)
AS
/* Create the Order header */
INSERT INTO psiOrders
(
customerID,
dateOrdered,
productOrdered,
quantity,
cost,
comments,
CCNum,
ExpDate,
CCV
)
VALUES
(
@customerID,
@dateOrdered,
@productOrdered ,
@quantity,
@cost,
@comments,
@CCNum,
@ExpDate,
@CCV
)
SELECT
@OrderID = @@Identity
GO
--------------------------
-----Query Analyzer Data---------------------
INSERT INTO psiOrders
(
customerID,
dateOrdered,
productOrdered,
quantity,
cost,
comments,
CCNum,
ExpDate,
CCV
)
VALUES
(
40,
9/22/2004,
'SSK Scooter Kit',
1,
$ 99.00,
'',
'55555555555555 55',
'06-2007',
'182'
)
SELECT
@@Identity
GO
--------------------------
Any ideas?
--------------------------------
From: Chad Micheal Lawson
-----------------------
Posted by a user from .NET 247 ( http://www.dotnet247.com/)
<Id>BqE+WdnJs0u NaGpvrOAVZw==</Id> 4 1830
When you declared the command object did you set the CommandType =
CommandType.Sto redProcedure?
Also you may want to run a sqltrace and watch Stored Procedure class.
What's the exact error and line that it fails on?
"Chad Micheal Lawson via .NET 247" wrote: I'm stumped at this point and I'm tired of trying things so I'm posting in hopes of some guru with a sharp eye. I have an asp.net app running on a local Win XP Pro box. Within the app, I call a SPROC and pass the info to the SQL box and it hiccups. I'll drop VS.NET into debug mode and step through the SPROC creation and copy those values into Query Analyzer to get a little more info. When I run the Query Analyer that data works just fine. What?! Here is the relevant info:
------ASP.NET CODE--------------------- Dim parameterCustID As SqlParameter = New SqlParameter("@ customerID", SqlDbType.Int, 4) parameterCustID .Value = customerID orderCommand.Pa rameters.Add(pa rameterCustID)
Dim parameterDateOr dered As SqlParameter = New SqlParameter("@ dateOrdered", SqlDbType.DateT ime, 8) parameterDateOr dered.Value = Today orderCommand.Pa rameters.Add(pa rameterDateOrde red)
Dim parameterProduc tOrdered As SqlParameter = New SqlParameter("@ productOrdered" , SqlDbType.VarCh ar, 50) parameterProduc tOrdered.Value = productOrdered orderCommand.Pa rameters.Add(pa rameterProductO rdered)
Dim parameterQuanti ty As SqlParameter = New SqlParameter("@ quantity", SqlDbType.Small Int, 2) parameterQuanti ty.Value = CInt(quantity) orderCommand.Pa rameters.Add(pa rameterQuantity )
Dim parameterCost As SqlParameter = New SqlParameter("@ cost", SqlDbType.Small Money, 4) parameterCost.V alue = price orderCommand.Pa rameters.Add(pa rameterCost)
Dim parameterCommen ts As SqlParameter = New SqlParameter("@ comments", SqlDbType.NVarC har, 255) parameterCommen ts.Value = Trim(txtComment s.Text) orderCommand.Pa rameters.Add(pa rameterComments )
Dim parameterCCNum As SqlParameter = New SqlParameter("@ CCNum", SqlDbType.VarCh ar, 50) parameterCCNum. Value = Trim(txtCardNum ber.Text) orderCommand.Pa rameters.Add(pa rameterCCNum)
Dim parameterExpDat e As SqlParameter = New SqlParameter("@ ExpDate", SqlDbType.VarCh ar, 50) parameterExpDat e.Value = expDate orderCommand.Pa rameters.Add(pa rameterExpDate)
Dim parameterCCV As SqlParameter = New SqlParameter("@ CCV", SqlDbType.VarCh ar, 3) parameterCCV.Va lue = Trim(Issue.Text ) orderCommand.Pa rameters.Add(pa rameterCCV)
Dim parameterorderI D As SqlParameter = New SqlParameter("@ orderID", SqlDbType.Int, 4) parameterorderI D.Direction = ParameterDirect ion.Output orderCommand.Pa rameters.Add(pa rameterorderID)
orderCommand.Ex ecuteNonQuery()
' Return the OrderID Dim orderID As Integer = parameterCustom erID.Value --------------------------
-------SPROC in SQL 2K------------------- CREATE Procedure addOrder ( @customerID int, @dateOrdered datetime, @productOrdered varchar(50), @quantity smallint, @cost smallmoney, @comments nvarchar(255), @CCNum varchar(50), @ExpDate varchar(50), @CCV varchar(3), @OrderID int OUTPUT )
AS
/* Create the Order header */ INSERT INTO psiOrders ( customerID, dateOrdered, productOrdered, quantity, cost, comments, CCNum, ExpDate, CCV ) VALUES ( @customerID, @dateOrdered, @productOrdered , @quantity, @cost, @comments, @CCNum, @ExpDate, @CCV ) SELECT @OrderID = @@Identity GO --------------------------
-----Query Analyzer Data--------------------- INSERT INTO psiOrders ( customerID, dateOrdered, productOrdered, quantity, cost, comments, CCNum, ExpDate, CCV ) VALUES ( 40, 9/22/2004, 'SSK Scooter Kit', 1, $ 99.00, '', '55555555555555 55', '06-2007', '182' ) SELECT @@Identity GO --------------------------
Any ideas?
-------------------------------- From: Chad Micheal Lawson
----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>BqE+WdnJs0u NaGpvrOAVZw==</Id>
Hi Chad:
Just one idea. You might want to try
SqlCommandBuild er.DeriveParame ters once, just to compare the
parameters it would select and compare them to the types and sizes you
have.
HTH,
--
Scott http://www.OdeToCode.com
On Thu, 23 Sep 2004 17:27:07 -0700, Chad Micheal Lawson via .NET 247
<an*******@dotn et247.com> wrote: I'm stumped at this point and I'm tired of trying things so I'm posting in hopes of some guru with a sharp eye. I have an asp.net app running on a local Win XP Pro box. Within the app, I call a SPROC and pass the info to the SQL box and it hiccups. I'll drop VS.NET into debug mode and step through the SPROC creation and copy those values into Query Analyzer to get a little more info. When I run the Query Analyer that data works just fine. What?! Here is the relevant info:
------ASP.NET CODE--------------------- Dim parameterCustID As SqlParameter = New SqlParameter("@ customerID", SqlDbType.Int, 4) parameterCustI D.Value = customerID orderCommand.P arameters.Add(p arameterCustID)
Dim parameterDateOr dered As SqlParameter = New SqlParameter("@ dateOrdered", SqlDbType.DateT ime, 8) parameterDateO rdered.Value = Today orderCommand.P arameters.Add(p arameterDateOrd ered)
Dim parameterProduc tOrdered As SqlParameter = New SqlParameter("@ productOrdered" , SqlDbType.VarCh ar, 50) parameterProdu ctOrdered.Value = productOrdered orderCommand.P arameters.Add(p arameterProduct Ordered)
Dim parameterQuanti ty As SqlParameter = New SqlParameter("@ quantity", SqlDbType.Small Int, 2) parameterQuant ity.Value = CInt(quantity) orderCommand.P arameters.Add(p arameterQuantit y)
Dim parameterCost As SqlParameter = New SqlParameter("@ cost", SqlDbType.Small Money, 4) parameterCost. Value = price orderCommand.P arameters.Add(p arameterCost)
Dim parameterCommen ts As SqlParameter = New SqlParameter("@ comments", SqlDbType.NVarC har, 255) parameterComme nts.Value = Trim(txtComment s.Text) orderCommand.P arameters.Add(p arameterComment s)
Dim parameterCCNum As SqlParameter = New SqlParameter("@ CCNum", SqlDbType.VarCh ar, 50) parameterCCNum .Value = Trim(txtCardNum ber.Text) orderCommand.P arameters.Add(p arameterCCNum)
Dim parameterExpDat e As SqlParameter = New SqlParameter("@ ExpDate", SqlDbType.VarCh ar, 50) parameterExpDa te.Value = expDate orderCommand.P arameters.Add(p arameterExpDate )
Dim parameterCCV As SqlParameter = New SqlParameter("@ CCV", SqlDbType.VarCh ar, 3) parameterCCV.V alue = Trim(Issue.Text ) orderCommand.P arameters.Add(p arameterCCV)
Dim parameterorderI D As SqlParameter = New SqlParameter("@ orderID", SqlDbType.Int, 4) parameterorder ID.Direction = ParameterDirect ion.Output orderCommand.P arameters.Add(p arameterorderID )
orderCommand.E xecuteNonQuery( )
' Return the OrderID Dim orderID As Integer = parameterCustom erID.Value --------------------------
-------SPROC in SQL 2K------------------- CREATE Procedure addOrder ( @customerID int, @dateOrdered datetime, @productOrdered varchar(50), @quantity smallint, @cost smallmoney, @comments nvarchar(255), @CCNum varchar(50), @ExpDate varchar(50), @CCV varchar(3), @OrderID int OUTPUT )
AS
/* Create the Order header */ INSERT INTO psiOrders ( customerID, dateOrdered, productOrdered, quantity, cost, comments, CCNum, ExpDate, CCV ) VALUES ( @customerID, @dateOrdered, @productOrdered , @quantity, @cost, @comments, @CCNum, @ExpDate, @CCV ) SELECT @OrderID = @@Identity GO --------------------------
-----Query Analyzer Data--------------------- INSERT INTO psiOrders ( customerID, dateOrdered, productOrdered, quantity, cost, comments, CCNum, ExpDate, CCV ) VALUES ( 40, 9/22/2004, 'SSK Scooter Kit', 1, $ 99.00, '', '55555555555555 55', '06-2007', '182' ) SELECT @@Identity GO --------------------------
Any ideas?
-------------------------------- From: Chad Micheal Lawson
----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>BqE+WdnJs0 uNaGpvrOAVZw==</Id>
>' Return the OrderID Dim orderID As Integer = parameterCustom erID.Value <<<wrong paramter???
Dim orderID As Integer = parameterOrderI D.Value
I find creating individual variables for each parameter error prone.
This is how I do it:
cmd.Parameters. Add("@EmpID", SqlDbType.Int). Value = empID
cmd.Parameters. Add("@WeekEnd", SqlDbType.Small DateTime).Value =
weekend
cmd.Parameters. Add("@TimeSheet ID", SqlDbType.Int). Direction =
ParameterDirect ion.Output
...
Dim TimeSheetID As Integer =
CType(cmd.Param eters("@TimeShe etID").Value, Integer)
HTH,
Greg
"Chad Micheal Lawson via .NET 247" <an*******@dotn et247.com> wrote in
message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
I'm stumped at this point and I'm tired of trying things so I'm posting in
hopes of some guru with a sharp eye. I have an asp.net app running on a
local Win XP Pro box. Within the app, I call a SPROC and pass the info to
the SQL box and it hiccups. I'll drop VS.NET into debug mode and step
through the SPROC creation and copy those values into Query Analyzer to get
a little more info. When I run the Query Analyer that data works just fine.
What?! Here is the relevant info:
------ASP.NET CODE---------------------
Dim parameterCustID As SqlParameter = New SqlParameter("@ customerID",
SqlDbType.Int, 4)
parameterCustID .Value = customerID
orderCommand.Pa rameters.Add(pa rameterCustID)
Dim parameterDateOr dered As SqlParameter = New SqlParameter("@ dateOrdered",
SqlDbType.DateT ime, 8)
parameterDateOr dered.Value = Today
orderCommand.Pa rameters.Add(pa rameterDateOrde red)
Dim parameterProduc tOrdered As SqlParameter = New
SqlParameter("@ productOrdered" , SqlDbType.VarCh ar, 50)
parameterProduc tOrdered.Value = productOrdered
orderCommand.Pa rameters.Add(pa rameterProductO rdered)
Dim parameterQuanti ty As SqlParameter = New SqlParameter("@ quantity",
SqlDbType.Small Int, 2)
parameterQuanti ty.Value = CInt(quantity)
orderCommand.Pa rameters.Add(pa rameterQuantity )
Dim parameterCost As SqlParameter = New SqlParameter("@ cost",
SqlDbType.Small Money, 4)
parameterCost.V alue = price
orderCommand.Pa rameters.Add(pa rameterCost)
Dim parameterCommen ts As SqlParameter = New SqlParameter("@ comments",
SqlDbType.NVarC har, 255)
parameterCommen ts.Value = Trim(txtComment s.Text)
orderCommand.Pa rameters.Add(pa rameterComments )
Dim parameterCCNum As SqlParameter = New SqlParameter("@ CCNum",
SqlDbType.VarCh ar, 50)
parameterCCNum. Value = Trim(txtCardNum ber.Text)
orderCommand.Pa rameters.Add(pa rameterCCNum)
Dim parameterExpDat e As SqlParameter = New SqlParameter("@ ExpDate",
SqlDbType.VarCh ar, 50)
parameterExpDat e.Value = expDate
orderCommand.Pa rameters.Add(pa rameterExpDate)
Dim parameterCCV As SqlParameter = New SqlParameter("@ CCV",
SqlDbType.VarCh ar, 3)
parameterCCV.Va lue = Trim(Issue.Text )
orderCommand.Pa rameters.Add(pa rameterCCV)
Dim parameterorderI D As SqlParameter = New SqlParameter("@ orderID",
SqlDbType.Int, 4)
parameterorderI D.Direction = ParameterDirect ion.Output
orderCommand.Pa rameters.Add(pa rameterorderID)
orderCommand.Ex ecuteNonQuery()
' Return the OrderID
Dim orderID As Integer = parameterCustom erID.Value
--------------------------
-------SPROC in SQL 2K-------------------
CREATE Procedure addOrder
(
@customerID int,
@dateOrdered datetime,
@productOrdered varchar(50),
@quantity smallint,
@cost smallmoney,
@comments nvarchar(255),
@CCNum varchar(50),
@ExpDate varchar(50),
@CCV varchar(3),
@OrderID int OUTPUT
)
AS
/* Create the Order header */
INSERT INTO psiOrders
(
customerID,
dateOrdered,
productOrdered,
quantity,
cost,
comments,
CCNum,
ExpDate,
CCV
)
VALUES
(
@customerID,
@dateOrdered,
@productOrdered ,
@quantity,
@cost,
@comments,
@CCNum,
@ExpDate,
@CCV
)
SELECT
@OrderID = @@Identity
GO
--------------------------
-----Query Analyzer Data---------------------
INSERT INTO psiOrders
(
customerID,
dateOrdered,
productOrdered,
quantity,
cost,
comments,
CCNum,
ExpDate,
CCV
)
VALUES
(
40,
9/22/2004,
'SSK Scooter Kit',
1,
$ 99.00,
'',
'55555555555555 55',
'06-2007',
'182'
)
SELECT
@@Identity
GO
--------------------------
Any ideas?
--------------------------------
From: Chad Micheal Lawson
-----------------------
Posted by a user from .NET 247 ( http://www.dotnet247.com/)
<Id>BqE+WdnJs0u NaGpvrOAVZw==</Id>
P.S.
SELECT @OrderID = @@Identity
can cause your problems (if you have triggers), better to use:
SELECT @OrderID = SCOPE_IDENTITY( )
Greg This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Punisher |
last post by:
Ok I'm trying to reference a specific node in a tree.
TreeNode nodeParentChannel = treeview1.Nodes;
It bugs out with this error: Input string was not in a correct format
Obviously 1.2 is not an int. How can I reference this node?
|
by: The Crow |
last post by:
if the reason for error is simple, excuse me. but i cant find what the
reason is. Here is the snippet :
string script = String.Format(@"<script src='common.js'
type='text/javascript'></script>
<script language='javascript' type='text/javascript'>
|
by: phmyhn |
last post by:
I have two web pages, one is viewlarger.aspx, another one is
shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart"
image button, the sub appends the id (passed from another page from a
hyperlink column) into a session. the code is as following:
Private Sub ibtAddtoCart_Click(ByVal sender As System.Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Handles
ibtAddtoCart.Click
idStr = Session("ids")
pid =...
|
by: John Chorlton |
last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code
Child form
public DataRowView SelectedAddres
ge
...
|
by: dan |
last post by:
I am using VB.NET 2003 and SQL Server 2000.
The program uses ADO.NET .
The following instruction:
Me.cd_insertDataRecord.ExecuteNonQuery()
throws this exception:
">>>ProcessDataRecord/ Exception: Type= System.FormatException Message: Input string was not in a correct format.
StackTrace: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
| |
by: James Pose |
last post by:
Convert.Int32 fails for "0" but works fine for all other numbers.
This does not work on one machine when "0" it works fine on other machines
Convert.ToInt32(“0”);
gives exception {"Input string was not in a correct format."}
If I specify base 10 this works on all machines
Convert.ToInt32(“0”,10);
So I have 3 related questions.
|
by: Pieter Coucke |
last post by:
Hi,
When a user types a non numeric-value in a numeric column in a DataGridView,
and he tries to leave the cell, he gets this "Input string was not in a
correct format."-exception.
Is there a (nice) way to get rid of this exception? And just put a "0" in
the place? Or somehow trigger this single exception (does exceptions have a
unique type-number?) and do some appropriate actions?
|
by: Jen |
last post by:
One user of my application is experiencing an exception "input string not in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an Int16
(using Convert.ToInt16). How can that be? There are other text boxes that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't...
|
by: muaddubby |
last post by:
Hi
I'm running into a scenario with a DataSet that has a schema loaded into it, tries to then load data (that matches the schema), and fails with a "Input string was not in a correct format" exception because the decimal field in one of the incoming fields is written in exponential form.
I've looked at generating the XML with a fully written decimal value (as opposed to using exponential notation) but that's an issue because right now the...
|
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,...
|
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...
| |
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...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |