Solved

VB.Net Input string was not in a correct format

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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 …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now