Showing posts with label stored. Show all posts
Showing posts with label stored. Show all posts

Saturday, March 31, 2012

String to Int error

Hello,

I need to convert a value from my textbox from string to int. It only hold the idea of an item and i need to send that as Stored Procedure value to fetch another value.
I now get the current error:

Input string was not in a correct format.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.FormatException: Input string was not in a correct format.

Source Error:

Line 97: Dim strComm As String = "spQMelderStatusGet"
Line 98: Dim str As String = Convert.ToString(lblStatus.Text)
Line 99: Dim ID As Int32 = Int32.Parse(str)
Line 100: Using loStat As SqlCommand = New SqlCommand(strComm)
Line 101:


Source File:D:\Source\Qualm\QMelder\StatusViewer.aspx.vb Line:99

And this is the code i'm using:

'Get status naamDim strCommAs String ="spQMelderStatusGet"Dim strAs String = Convert.ToString(lblStatus.Text)
Dim IDAs Int32 = Int32.Parse(str)
Using loStatAs SqlCommand =New SqlCommand(strComm)

Dim StatIDAs New SqlParameter()
StatID.ParameterName ="@dotnet.itags.org.StatusID" StatID.SqlDbType = SqlDbType.Int StatID.Direction = ParameterDirection.InputOutput StatID.Size = 2 StatID.Value = ID loStat.Parameters.Add(StatID) loStat.Connection = loConn loStat.CommandType = CommandType.StoredProcedure statReader = loStat.ExecuteReader lblStatus.Text = statReader("StatusNaam")
End Using

statReader.Close()


I've tried all kinds of ways, like converting the txtbox value to string and then to int but keep giving the same error, so most likely those codes weren't the right ones either.

If someone could help me out, tnx alot in advance.

Anoiks

Hi

before parsing String value in integer, check it's value ..

i hope . in ur case it's value is NULL or any Literal word


Hi

Hope I have understood your problem correctly.

Have you tried Convert.ToInt32("string").

But as I write, If the parse function you used fails to convert the string to integer, then may be the value entered in the text box either is non-convertible to integer data type or a conversion results in a out of range value. If you beleive it is a large integer value, can you try using a "float" or a "double" data type.

Worse case, can you convert your stored procedure type to accept an integer, I hope that is not hindering your requirement.

VJ


ok that was a stupid mistake, thanks alot i was too focussed on that part of code.
So i didnt notice i didnt fill the string in codes before that.Geeked

Thursday, March 22, 2012

Strongly Type Datasets

I am trying to create a strongly typed dataset is VS 2005 with the VS
creating the stored procedures. It won't create the stored procedures. The
SQL script it generates is based on a SQL login so the script looks
something like:

DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE

these scripts won't work until I change the script to:

DROP PROCEDURE dbo.WEB_PAGE_UPDATE

What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.

Regards, Chris.Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table name.

"Chris" <nospam@.nospam.comwrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>I am trying to create a strongly typed dataset is VS 2005 with the VS
>creating the stored procedures. It won't create the stored procedures. The
>SQL script it generates is based on a SQL login so the script looks
>something like:
>
DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>
these scripts won't work until I change the script to:
>
DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>
What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.
>
Regards, Chris.
>


No I can't find it. Any clues where abouts I might find it. I have looked on
the properties on of the dataset etc.

"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table
name.
>
"Chris" <nospam@.nospam.comwrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures. The
>>SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>these scripts won't work until I change the script to:
>>
>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>What am I doing wrong? I suspect I doing my connectionstring wrong in
>some way or my permissions are wrong in SQL Server.
>>
>Regards, Chris.
>>


>
>


Which version of SQL Server? If 2005, go to the properties page of the login
you are using (via Management Studio), and check the value for Default
Schema for that login. My guess is that it's not dbo. But this is just a
guess.

"Chris" <nospam@.nospam.comwrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

No I can't find it. Any clues where abouts I might find it. I have looked
on the properties on of the dataset etc.
>
"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>Is there a setting for the database "Schema Name" somewhere on the
>properties of the data set? That's what's being prepended to the table
>name.
>>
>"Chris" <nospam@.nospam.comwrote in message
>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>>creating the stored procedures. It won't create the stored procedures.
>>>The SQL script it generates is based on a SQL login so the script looks
>>>something like:
>>>
>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>>
>>these scripts won't work until I change the script to:
>>>
>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>>
>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>some way or my permissions are wrong in SQL Server.
>>>
>>Regards, Chris.
>>>


>>
>>


>
>


Sorry I must be missing something. When you say "check for default schema",
I can't find it it. It is SQL 2005. I have gone to the login propeties page
of the login (in SQL 2005), gone to user mapping and put the default scheme
over to do_owner but the sql scripts generated are still this same in VS
2005

"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

Which version of SQL Server? If 2005, go to the properties page of the
login you are using (via Management Studio), and check the value for
Default Schema for that login. My guess is that it's not dbo. But this is
just a guess.
>
"Chris" <nospam@.nospam.comwrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>No I can't find it. Any clues where abouts I might find it. I have looked
>on the properties on of the dataset etc.
>>
>"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
>news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>>Is there a setting for the database "Schema Name" somewhere on the
>>properties of the data set? That's what's being prepended to the table
>>name.
>>>
>>"Chris" <nospam@.nospam.comwrote in message
>>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures.
>>The SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>>>these scripts won't work until I change the script to:
>>
>>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>>some way or my permissions are wrong in SQL Server.
>>
>>>Regards, Chris.
>>
>>>
>>>


>>
>>


>
>


"db_owner" is a role, not a schema; "dbo" is a schema.

When you look at the name of the table in the Object Explorer (of Management
Studio), what is it? Is it dbo.TableName, or WebManagerV2.TableName?

"Chris" <nospam@.nospam.comwrote in message
news:O7PiG6KoHHA.5052@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Sorry I must be missing something. When you say "check for default
schema", I can't find it it. It is SQL 2005. I have gone to the login
propeties page of the login (in SQL 2005), gone to user mapping and put
the default scheme over to do_owner but the sql scripts generated are
still this same in VS 2005
>
>
"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>Which version of SQL Server? If 2005, go to the properties page of the
>login you are using (via Management Studio), and check the value for
>Default Schema for that login. My guess is that it's not dbo. But this is
>just a guess.
>>
>"Chris" <nospam@.nospam.comwrote in message
>news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>>No I can't find it. Any clues where abouts I might find it. I have
>>looked on the properties on of the dataset etc.
>>>
>>"KJ" <n_o_s_p_a__M@.Mail.comwrote in message
>>news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
>>>Is there a setting for the database "Schema Name" somewhere on the
>>>properties of the data set? That's what's being prepended to the table
>>>name.
>>
>>>"Chris" <nospam@.nospam.comwrote in message
>>>news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>>I am trying to create a strongly typed dataset is VS 2005 with the VS
>>creating the stored procedures. It won't create the stored procedures.
>>The SQL script it generates is based on a SQL login so the script looks
>>something like:
>>
>>DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
>>
>>these scripts won't work until I change the script to:
>>
>>DROP PROCEDURE dbo.WEB_PAGE_UPDATE
>>
>>What am I doing wrong? I suspect I doing my connectionstring wrong in
>>some way or my permissions are wrong in SQL Server.
>>
>>Regards, Chris.
>>
>>
>>
>>>
>>>


>>
>>


>
>

Strongly Type Datasets

I am trying to create a strongly typed dataset is VS 2005 with the VS
creating the stored procedures. It won't create the stored procedures. The
SQL script it generates is based on a SQL login so the script looks
something like:
DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
these scripts won't work until I change the script to:
DROP PROCEDURE dbo.WEB_PAGE_UPDATE
What am I doing wrong? I suspect I doing my connectionstring wrong in some
way or my permissions are wrong in SQL Server.
Regards, Chris.Is there a setting for the database "Schema Name" somewhere on the
properties of the data set? That's what's being prepended to the table name.
"Chris" <nospam@.nospam.com> wrote in message
news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>I am trying to create a strongly typed dataset is VS 2005 with the VS
>creating the stored procedures. It won't create the stored procedures. The
>SQL script it generates is based on a SQL login so the script looks
>something like:
> DROP PROCEDURE WebManagerV2.WEB_PAGE_UPDATE
> these scripts won't work until I change the script to:
> DROP PROCEDURE dbo.WEB_PAGE_UPDATE
> What am I doing wrong? I suspect I doing my connectionstring wrong in some
> way or my permissions are wrong in SQL Server.
> Regards, Chris.
>
Which version of SQL Server? If 2005, go to the properties page of the login
you are using (via Management Studio), and check the value for Default
Schema for that login. My guess is that it's not dbo. But this is just a
guess.
"Chris" <nospam@.nospam.com> wrote in message
news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...
> No I can't find it. Any clues where abouts I might find it. I have looked
> on the properties on of the dataset etc.
> "KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
> news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
>
No I can't find it. Any clues where abouts I might find it. I have looked on
the properties on of the dataset etc.
"KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
news:OFjUR$GoHHA.716@.TK2MSFTNGP05.phx.gbl...
> Is there a setting for the database "Schema Name" somewhere on the
> properties of the data set? That's what's being prepended to the table
> name.
> "Chris" <nospam@.nospam.com> wrote in message
> news:OdiLaBGoHHA.4412@.TK2MSFTNGP02.phx.gbl...
>
Sorry I must be missing something. When you say "check for default schema",
I can't find it it. It is SQL 2005. I have gone to the login propeties page
of the login (in SQL 2005), gone to user mapping and put the default scheme
over to do_owner but the sql scripts generated are still this same in VS
2005
"KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...
> Which version of SQL Server? If 2005, go to the properties page of the
> login you are using (via Management Studio), and check the value for
> Default Schema for that login. My guess is that it's not dbo. But this is
> just a guess.
> "Chris" <nospam@.nospam.com> wrote in message
> news:OxkTYdHoHHA.4124@.TK2MSFTNGP02.phx.gbl...
>
"db_owner" is a role, not a schema; "dbo" is a schema.
When you look at the name of the table in the Object Explorer (of Management
Studio), what is it? Is it dbo.TableName, or WebManagerV2.TableName?
"Chris" <nospam@.nospam.com> wrote in message
news:O7PiG6KoHHA.5052@.TK2MSFTNGP04.phx.gbl...
> Sorry I must be missing something. When you say "check for default
> schema", I can't find it it. It is SQL 2005. I have gone to the login
> propeties page of the login (in SQL 2005), gone to user mapping and put
> the default scheme over to do_owner but the sql scripts generated are
> still this same in VS 2005
>
> "KJ" <n_o_s_p_a__M@.Mail.com> wrote in message
> news:O7IrnYJoHHA.1476@.TK2MSFTNGP03.phx.gbl...
>
http://Pamela-Anderson-in-nylons.in...p?movie=1673286