Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.Net Input string was not in a correct format

Posted on 2011-09-14
5
Medium Priority
?
264 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 1000 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 1000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

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…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

610 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