Solved

VB.Net Input string was not in a correct format

Posted on 2011-09-14
5
261 Views
Last Modified: 2012-05-12
I have code that I've used in 3.5 and works. 4.0 for some reason doesn't work.

I placed the information below.

Thx
Dim TotNumRows As New SqlParameter("@TotNumRows", SqlDbType.Int)
        TotNumRows.Value = Nothing
        TotNumRows.Direction = ParameterDirection.Output
        DataAdapter.SelectCommand.Parameters.Add(TotNumRows)
        DataAdapter.SelectCommand.Parameters("@TotNumRows").Value = Nothing


I will call a public Sub from here and it bombs with the Input String was not in correct format.
avigation(Convert.ToInt32(TotNumRows.Value.ToString()))

Here is the sub I call

  Public Sub Navigation(ByVal totalRows As Integer)
  End Sub

Open in new window

0
Comment
Question by:jeffreyjseaman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 250 total points
ID: 36535640
you need tochange nothing to integer value like 0

TotNumRows.Value = Nothing

must be

TotNumRows.Value = 0

Dim TotNumRows As New SqlParameter("@TotNumRows", SqlDbType.Int)
        TotNumRows.Value = 0
        TotNumRows.Direction = ParameterDirection.Output
        DataAdapter.SelectCommand.Parameters.Add(TotNumRows)
        DataAdapter.SelectCommand.Parameters("@TotNumRows").Value = 0
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 250 total points
ID: 36536366
You assign Nothing as a value to the parameter. Is this an error or is this because you want to pass Null?
0
 

Author Comment

by:jeffreyjseaman
ID: 36540744
I can't use TotNumRows = 0, Because @TotNumRows is an Output Parameter from SQL Server. It does a row count of the total number of records I'll be using. It sends it back to .Net.

0
 

Author Comment

by:jeffreyjseaman
ID: 36540791
@JamesBurger & pratima_mcs:

I resolved this on my own. My own stupidity.  I didn't set my row count in the Procedure. This fixed it.
Resolution:
SET @TotNumRows = @@ROWCOUNT
0
 

Author Closing Comment

by:jeffreyjseaman
ID: 36540794
Thanks
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question