Solved

VB.Net Input string was not in a correct format

Posted on 2011-09-14
5
256 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
@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
Comment Utility
Thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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 …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

13 Experts available now in Live!

Get 1:1 Help Now