473,396 Members | 2,009 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,396 software developers and data experts.

Convert variable to integer

I need to input a stored procedure parameter as an integer but the
conversion doesn't work. I get the error message "Input string was not
in a correct format." I'm using the following code:

Dim intObjectID As Integer = Convert.ToInt32(row.Cells(0).Text)

With myCommand
..Parameters.Add(New SqlParameter("@ObjectID", SqlDbType.Int))
..Parameters("@ObjectID").Value = intObjectID

Can someone please help me?

// S

Oct 27 '06 #1
2 1606
It looks like the text in that cell was not a valid integer. You can't
convert a string that doesn't contain an integer into one.

<st****@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
>I need to input a stored procedure parameter as an integer but the
conversion doesn't work. I get the error message "Input string was not
in a correct format." I'm using the following code:

Dim intObjectID As Integer = Convert.ToInt32(row.Cells(0).Text)

With myCommand
.Parameters.Add(New SqlParameter("@ObjectID", SqlDbType.Int))
.Parameters("@ObjectID").Value = intObjectID

Can someone please help me?

// S

Oct 27 '06 #2
Are you absolutely sure the cell'e text (row.Cells(0).Text) is numeric?

<st****@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
>I need to input a stored procedure parameter as an integer but the
conversion doesn't work. I get the error message "Input string was not
in a correct format." I'm using the following code:

Dim intObjectID As Integer = Convert.ToInt32(row.Cells(0).Text)

With myCommand
.Parameters.Add(New SqlParameter("@ObjectID", SqlDbType.Int))
.Parameters("@ObjectID").Value = intObjectID

Can someone please help me?

// S

Oct 27 '06 #3

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

Similar topics

1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
5
by: da Vinci | last post by:
Hi Gents, This is what I am trying to do. Say you have a double or a float with the value 14.5624 for example. How could I take that variable and get the 14 into an integer variable and the...
5
by: IamZadok | last post by:
Hi I was wondering if anyone knew how to convert a string or an integer into a Static Char. Thx
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
3
by: priyanka | last post by:
Hi there, I want to convert a String into integer. I get the string from a file using : string argNum; getline(inputStream,argNum); I now need to convert argNum into integer.
8
by: Polaris431 | last post by:
I have a buffer that holds characters. Four characters in a row represent an unsigned 32 bit value. I want to convert these characters to a 32 bit value. For example: char buffer; buffer =...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
10
by: cmdolcet69 | last post by:
Public ArrList As New ArrayList Public bitvalue As Byte() Public Sub addvalues() Dim index As Integer ArrList.Add(100) ArrList.Add(200) ArrList.Add(300) ArrList.Add(400) ArrList.Add(500)
2
by: =?Utf-8?B?WVhR?= | last post by:
Hello, I want to convert the timespan (1.12:25:23) to 1day 12hour 25min 23sec, how to do it? thank you.
14
by: rtillmore | last post by:
Hello, I did a quick google search and nothing that was returned is quite what I am looking for. I have a 200 character hexadecimal string that I need to convert into a 100 character string. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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...
0
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,...

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.