This is new to me. I am trying to call a SP (MS SQL) and pass different data
types. I know in SQL you handel these data types diffent in your string
Public Shared Function GetGridDataSet(ByVal val1 As Integer, ByVal val2 As
String) As DataSet
Dim UserData As DataSet
Dim myConnection As SqlConnection
Dim myCommand As SqlDataAdapter
myConnection = New SqlConnection(ConnectionString)
myCommand = New SqlDataAdapter("Exec ap_ExpressOnLineCheckoutForASP
'" + val1 + "','" + val2 + "'", myConnection)
UserData = New DataSet
myCommand.Fill(UserData, "DealConfirm")
myConnection.Close()
Return UserData
End Function
I am getting this error:" Input string was not in a correct format."
Can someone point me to a link that can help me get my sting right (Date,
Int, Dbl,)
Thanks 4 2797
Your val1 is an integer. VB.NET doesn't convert an Integer to a String
automatically when using + to concatenate. Either change + to & or use
val1.ToString() to get String value.
"BrianDH" <No**********@nospam.com> wrote in message
news:k_********************@telcove.net... This is new to me. I am trying to call a SP (MS SQL) and pass different
data types. I know in SQL you handel these data types diffent in your string
Public Shared Function GetGridDataSet(ByVal val1 As Integer, ByVal val2 As String) As DataSet Dim UserData As DataSet Dim myConnection As SqlConnection Dim myCommand As SqlDataAdapter myConnection = New SqlConnection(ConnectionString) myCommand = New SqlDataAdapter("Exec
ap_ExpressOnLineCheckoutForASP '" + val1 + "','" + val2 + "'", myConnection) UserData = New DataSet myCommand.Fill(UserData, "DealConfirm") myConnection.Close() Return UserData End Function I am getting this error:" Input string was not in a correct format."
Can someone point me to a link that can help me get my sting right (Date, Int, Dbl,)
Thanks
OK no i awant it to be an Int. The SP is looking for an Int and a String.
I'll try the + to &.. but does the '" val1 '" or ' val ' have anything to do
with it like when writing a SQL statment?
"Matt" <ki*******@hotmail.com> wrote in message
news:EewQc.18500$Jo1.8815@lakeread01... Your val1 is an integer. VB.NET doesn't convert an Integer to a String automatically when using + to concatenate. Either change + to & or use val1.ToString() to get String value.
"BrianDH" <No**********@nospam.com> wrote in message news:k_********************@telcove.net... This is new to me. I am trying to call a SP (MS SQL) and pass different data types. I know in SQL you handel these data types diffent in your string
Public Shared Function GetGridDataSet(ByVal val1 As Integer, ByVal val2
As String) As DataSet Dim UserData As DataSet Dim myConnection As SqlConnection Dim myCommand As SqlDataAdapter myConnection = New SqlConnection(ConnectionString) myCommand = New SqlDataAdapter("Exec ap_ExpressOnLineCheckoutForASP '" + val1 + "','" + val2 + "'", myConnection) UserData = New DataSet myCommand.Fill(UserData, "DealConfirm") myConnection.Close() Return UserData End Function I am getting this error:" Input string was not in a correct format."
Can someone point me to a link that can help me get my sting right
(Date, Int, Dbl,)
Thanks
"BrianDH" <No**********@nospam.com> wrote in message
news:V8********************@telcove.net... OK no i awant it to be an Int. The SP is looking for an Int and a String.
I'll try the + to &.. but does the '" val1 '" or ' val ' have anything to
do with it like when writing a SQL statment?
You are building a string to supply to the SqlDataAdapter. You are
attempting to concatenate a variable of type Integer into that string. You
cannot do that with the + operator without explicitly converting that
variable to a string.
This has nothing to do with whether SQL Server will interpret the parameters
of the SQL stored procedure call as ints or varchars or whatever. The is
controlled solely by whether those values are in apostrophes or not.
OK found my answer.
Dim CN As Data.SqlClient.SqlConnection
Dim ConnectionString As String = "Server=SQLSERVER bla bla bla"
CN = New SqlClient.SqlConnection(ConnectionString)
CN.Open()
Dim cmd As New SqlClient.SqlCommand("ap_ExpressOnLineCheckoutForA SP", CN)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@intDealTypeID", SqlDbType.Int).Value = val1
cmd.Parameters.Add("@intProductTypeID", SqlDbType.VarChar).Value = val2
Dim da As New SqlClient.SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "Products")
Return ds
"BrianDH" <No**********@nospam.com> wrote in message
news:k_********************@telcove.net... This is new to me. I am trying to call a SP (MS SQL) and pass different
data types. I know in SQL you handel these data types diffent in your string
Public Shared Function GetGridDataSet(ByVal val1 As Integer, ByVal val2 As String) As DataSet Dim UserData As DataSet Dim myConnection As SqlConnection Dim myCommand As SqlDataAdapter myConnection = New SqlConnection(ConnectionString) myCommand = New SqlDataAdapter("Exec
ap_ExpressOnLineCheckoutForASP '" + val1 + "','" + val2 + "'", myConnection) UserData = New DataSet myCommand.Fill(UserData, "DealConfirm") myConnection.Close() Return UserData End Function I am getting this error:" Input string was not in a correct format."
Can someone point me to a link that can help me get my sting right (Date, Int, Dbl,)
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: GGG |
last post by:
I have a situation where at tool is passing me a large array of
strings that I need to process in a particular type of data. Each item
in the array gets to me as a pair of std::strings, basically,...
|
by: Shailesh Humbad |
last post by:
I wrote a short page as a quick reference to c++ integer data types.
Any feedback welcome: http://www.somacon.com/blog/page11.php
|
by: theshowmecanuck |
last post by:
As a matter of academic interest only, is there a way to programmatically
list the 'c' data types? I am not looking for detail, just if it is
possible, and what function could be used to...
|
by: ramu |
last post by:
Hi,
I want to call a vc++ function from a c program on linux. So
when I do this dosen't the VC++ datatypes differ with c datatypes.
Because we don't have some vc++ data types in c. I have to...
|
by: mesut demir |
last post by:
Hi All,
When I create fields (in files) I need assign a data type like char,
varchar, money etc.
I have some questions about the data types when you create fields in a
file.
What is the...
|
by: Arpan |
last post by:
The .NET Framework 2.0 documentation states that
An Object variable always holds a pointer to the data, never the data
itself.
Now w.r.t. the following ASP.NET code snippet, can someone please...
|
by: Joel Hedlund |
last post by:
Hi!
The question of type checking/enforcing has bothered me for a while, and
since this newsgroup has a wealth of competence subscribed to it, I
figured this would be a great way of learning...
|
by: psbasha |
last post by:
Hi ,
When ever we read any data from file ,we read as a single line string ,and we convert the respective field data available in that string based on the data type ( say int,float ).
...
|
by: Alex |
last post by:
Hi,
I have three different data types coming out of my SQL tables that I
need to align with my VB code and the data set properties. I'm
getting an error message that reads "SQL exception...
|
by: Hags007 |
last post by:
I have a XML file I am working with. This file has been created by hand and I now need to develop a PHP script that will create it in the same format.
Here is what I have thus far:
$query =...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |