Solved

VB.Net Input string was not in a correct format

Posted on 2011-09-14
5
260 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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