Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Saturday, March 31, 2012

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

Strange error mblè mblè :)


Dim SQL = "SELECT confermato, confrndnum FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs
Dim RsCommand = New OleDbCommand(Sql, Conn)
Dim RsRecordCount = RsCommand.ExecuteScalar()

If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie = Request.Cookies("tristizia_auth")
ltrUsername.Text = ReadCookie("Username")
divConfOp.Visible = TRUE
End If


the line "If RsRecordCount = 0 Then" gives error
The error is strange becouse if RsRecordCount is 0 the page works, if not it gives the error

Thanks for any answer
Bye
. AtariVerify that the following line is not returning NULL. If it is and you are trying to put it into a string then it won't work of course. The line below is defiantely your problem I think though.


ltrUsername.Text = ReadCookie("Username")

Ok tryed, but the error appears =

I tryed either so:


If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie = Request.Cookies("tristizia_auth")
If Not ReadCookie Is Nothing Then
ltrUsername.Text = ReadCookie("Username")
Else
ltrUsername.Text = "[Unsknown]"
End If
divConfOp.Visible = TRUE
End If

But however I get error either so :


If RsRecordCount = 0 Then
divErrEx.Visible = True
Else
Dim MyVar = "ewruowehr"
End If

Boh?!?!

Bye
. Atari
One more victim of the Visual Basic type sloppiness (which is a feature).
Try to Dim ReadCookie as HttpCookie, just to be sure you don't get a string instead.
Uhm nothing is changed...


Dim Conn = New OleDbConnection("Provider = Microsoft.Jet.OleDb.4.0;Data Source=" & Server.MapPath("/mdb-database/tristizia.mdb"))
Conn.Open()
Dim SQL = "SELECT confermato, confrndnum FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs
Dim RsCommand = New OleDbCommand(Sql, Conn)
Dim RsRecordCount = RsCommand.ExecuteScalar()

<b style="color:red;">If RsRecordCount = 0 Then</b>
divErrEx.Visible = True
Else
SQL = "UPDATE utenti SET confermato = 'true' WHERE ConfRndNum = " & QS
RsCommand = New OleDbCommand(Sql, Conn)
RsCommand.ExecuteNonQuery()
Dim ReadCookie As HttpCookie = Request.Cookies("tristizia_auth")
If Not ReadCookie Is Nothing Then
ltrUsername.Text = ReadCookie("Username")
Else
ltrUsername.Text = "[Sconosciuto]"
End If
divConfOp.Visible = TRUE
End If

But what's the problem? I need to declare AS [type] the variables ? If so what's RsRecordCount ? I tryed As Integer but doesn't work...

Bye
. Atari
It's always better to declare the type of your variables. Not declaring it is a source of bugs.
Why do you use ExecuteScalar here, whereas your query returns two different columns? ExecuteScalar returns the first column of the first row. Here, it would be confermato. Is this column an integer?
In this case, you can Dim RsRecordCount as Integer = CType(RsCommand.ExecuteScalar(), Integer), but I suspect this is not what you're trying to do...
Your query should probably be "SELECT COUNT(*) FROM utenti WHERE confermato = 'false' AND confrndnum = " & Qs

System.IndexOutOfRangeException

I'm seeing the above error message appear on a web form. All the formcode-behind does is grab data from a SQL Server db (2005 Beta) andwrite it out in specfied controls.
The line that throws up the error is the following:
<code>
Line 150: txtCoDeath1a.Text = dtr("COD1a")
</code>
'Dtr' is simply a datareader that has been initialised previously. Iknow I should be checking for nulls in the db, but that isn't theproblem in this instant as the record I'm grabbing does have data forthe field 'COD1a'. It's of type nvarchar, length 150.
I've googled this error and have not found anything that seems directly relevant.
I'm using VB.
Any help much appreciated.

try putting this before your code

if dtr.Read then
dtr("COD1a")
end if


Sorry Chris, I should've posted more of my code.
I already have those lines in the code.
Any other ideas?

Try this

if not System.DBNull(dtr("COD1a")) then

txtCoDeath1a.Text = dtr("COD1a")

end if

Could you post more of your code? Are results coming back from the database? Is there a field called COD1a?


Thanks for the help guys, but I've located the source of theproblem. Very simple; I'd misnamed 'Cod1a'. Its actually 'CodIa'. Spotthe difference? Neither did I for a while!
<Sheepish> Sorry and thanks again.

Wednesday, March 28, 2012

System.InvalidCastException: Specified cast is not valid.

i'm retrieving data with Repeater from Sql Database. i have color colums in the table.. such as color1, color2, color3, color4 and columns type Nvarchar.

i implemented below the function to get team colors instead of characters in the table cells

---- function -----

string Team_Colours(string color)
{
switch (color)
{
case "WHITE" :
color = "#FFFFFF";
break;

case "BLACK" :
color = "#000000";
break;

case "RED" :
color = "#FF0000";
break;
case "" : // i think problem is here

color = "";
break;
}

return color;
}

-----------

if all color colums are not null, everything okay.. but, i'm getting below the error if any color colums is null..

------error-----

Exception Details: System.InvalidCastException: Specified cast is not valid.

Line 159: <td bgcolor="<%# Team_Colors((string) DataBinder.Eval(Container.DataItem, "color4")) %>"
------------
how can i solve this problem ?

thanks..If it's Null at times, try Switch(color.ToString())
Or add the .ToString to where the color is actually being read from the database.

Hope this helps, but may need to see more code...

Zath
i tried that Switch(color.ToString()) but same eror :(
it's ok, thanks Zath..

<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color1").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color2").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color3").ToString()) %>
<%# Team_Colors(DataBinder.Eval(Container.DataItem, "color4").ToString()) %>
I just tried your function and it works ok for me.
Are there any other colors in the database not accounted for?

Have you tried setting a break point in your code to help debug?

Maybe a little more code might help.

Zath

Thursday, March 22, 2012

System.NullReferenceException: Object reference not set to an instance of an object.

Hello:

I have a component that returns a value from a Sql Count statement... unfortunately I get the following error: System.NullReferenceException: Object reference not set to an instance of an object.

My component code:

Function GetCount(varAccountNumber as String) as String
conSqlConnect = New SqlConnection( "..." )
conSqlConnect.Open()
cmdSelect = New SqlCommand( "SELECT Count([account number]) AS Total From some_table Where [account number]=@dotnet.itags.org.accountnumber", conSqlConnect )
cmdSelect.Parameters.Add( "@dotnet.itags.org.accountnumber", varAccountNumber )
Return (cmdselect.executescalar())
conSqlConnect.Close()
End Function

on my code-behind page. I have

If myComponent.GetCount(user.identity.name) = 0 Then
'do something
End If

any suggestions?Which line caused this error?
>>Which line caused this error?

If myComponent.GetCount(user.identity.name) = 0 Then

What is "myComponent" ? It seems that it is not set correctly. Make sure that you initialize it the way it needs to be.
Yes I did initialize mycomponent like so:

Dim MyComponent as MyComponentClass
myComponent = New MyComponentClass()

any suggestions?
Either the component or the user.identity.name is causing the error. Try to debug the GetCount function of your component and also check if user.identity.name contains any value. At last I would say that debugging is the only way. Try quickwatch in Visual Studio.
Hope that it helped at least a little bit.

System.OutOfMemoryException

Hi,
We have an application using .NET framework 1.1 and SQL Server 2000. The
application seems to be running very well until we get an OutOfMemory error.
The computer has enough memory, in fact, when the error takes place there
are 2 GB available in physical memory.
Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
before recycling.This made the session information be lost quite often, so,
we decided to increase the limitation to 3GB and then, we got the
OutOfMemory error, although our server has 8GB of physical memory and only
3GB is used by SQL Server. Now we have the Maximum used memory (in
megabytes) to 2100.
Do you have any clue about why we have memory problems when there are 2GB of
physical memory available?
Thank you very much,
Any guidance will be appreciated.A common source of memory problems is not closing database connections.
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitaresto> wrote in message
news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...
> Hi,
> We have an application using .NET framework 1.1 and SQL Server 2000. The
> application seems to be running very well until we get an OutOfMemory
> error. The computer has enough memory, in fact, when the error takes place
> there are 2 GB available in physical memory.
> Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
> before recycling.This made the session information be lost quite often,
> so, we decided to increase the limitation to 3GB and then, we got the
> OutOfMemory error, although our server has 8GB of physical memory and only
> 3GB is used by SQL Server. Now we have the Maximum used memory (in
> megabytes) to 2100.
> Do you have any clue about why we have memory problems when there are 2GB
> of physical memory available?
> Thank you very much,
> Any guidance will be appreciated.
>
unless your running 64 bit or 32bit with the 3gb switch, 2gb is the max you
can set the memory to.
-- bruce (sqlwork.com)
"Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitaresto> wrote in message
news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...
> Hi,
> We have an application using .NET framework 1.1 and SQL Server 2000. The
> application seems to be running very well until we get an OutOfMemory
> error. The computer has enough memory, in fact, when the error takes place
> there are 2 GB available in physical memory.
> Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
> before recycling.This made the session information be lost quite often,
> so, we decided to increase the limitation to 3GB and then, we got the
> OutOfMemory error, although our server has 8GB of physical memory and only
> 3GB is used by SQL Server. Now we have the Maximum used memory (in
> megabytes) to 2100.
> Do you have any clue about why we have memory problems when there are 2GB
> of physical memory available?
> Thank you very much,
> Any guidance will be appreciated.
>
Thank you very much for your help. I have the /3GB in our boot.ini file:
[boot loader]
redirect=UseBiosSettings
timeout=30
default=multi(0)disk(0)rdisk(0)partition
(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WIND
OWS="Windows Server 2003, Enterprise
3GB" /fastdetect /3GB /PAE /redirect /NoExecute=OptOut
Are there anything else we can do in order w3wp.exe to be able to use more
than 2 GB?
Thanks a lot.
"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com>
escribi en el mensaje news:%237F$M4ZCHHA.5012@.TK2MSFTNGP06.phx.gbl...
> unless your running 64 bit or 32bit with the 3gb switch, 2gb is the max
> you can set the memory to.
> -- bruce (sqlwork.com)
> "Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitaresto> wrote in message
> news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...
>
Are you doing any work like dynamically generating images using GDI?
If so you might want to make sure that the code cleans up after itself
correctly or your server memory will go through the roof!
On Thu, 16 Nov 2006 08:16:08 +0100, "Carmen"
<quitaresto@.cpachecoe@.fcc.es@.quitaresto> wrote:

>Hi,
>We have an application using .NET framework 1.1 and SQL Server 2000. The
>application seems to be running very well until we get an OutOfMemory error
.
>The computer has enough memory, in fact, when the error takes place there
>are 2 GB available in physical memory.
>Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
>before recycling.This made the session information be lost quite often, so,
>we decided to increase the limitation to 3GB and then, we got the
>OutOfMemory error, although our server has 8GB of physical memory and only
>3GB is used by SQL Server. Now we have the Maximum used memory (in
>megabytes) to 2100.
>Do you have any clue about why we have memory problems when there are 2GB o
f
>physical memory available?
>Thank you very much,
>Any guidance will be appreciated.
>
--
Bits.Bytes.
http://bytes.thinkersroom.com

System.OutOfMemoryException

Hi,

We have an application using .NET framework 1.1 and SQL Server 2000. The
application seems to be running very well until we get an OutOfMemory error.
The computer has enough memory, in fact, when the error takes place there
are 2 GB available in physical memory.
Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
before recycling.This made the session information be lost quite often, so,
we decided to increase the limitation to 3GB and then, we got the
OutOfMemory error, although our server has 8GB of physical memory and only
3GB is used by SQL Server. Now we have the Maximum used memory (in
megabytes) to 2100.
Do you have any clue about why we have memory problems when there are 2GB of
physical memory available?

Thank you very much,
Any guidance will be appreciated.A common source of memory problems is not closing database connections.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitarestowrote in message
news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

Hi,
>
We have an application using .NET framework 1.1 and SQL Server 2000. The
application seems to be running very well until we get an OutOfMemory
error. The computer has enough memory, in fact, when the error takes place
there are 2 GB available in physical memory.
Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
before recycling.This made the session information be lost quite often,
so, we decided to increase the limitation to 3GB and then, we got the
OutOfMemory error, although our server has 8GB of physical memory and only
3GB is used by SQL Server. Now we have the Maximum used memory (in
megabytes) to 2100.
Do you have any clue about why we have memory problems when there are 2GB
of physical memory available?
>
Thank you very much,
Any guidance will be appreciated.
>


unless your running 64 bit or 32bit with the 3gb switch, 2gb is the max you
can set the memory to.

-- bruce (sqlwork.com)

"Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitarestowrote in message
news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

Hi,
>
We have an application using .NET framework 1.1 and SQL Server 2000. The
application seems to be running very well until we get an OutOfMemory
error. The computer has enough memory, in fact, when the error takes place
there are 2 GB available in physical memory.
Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
before recycling.This made the session information be lost quite often,
so, we decided to increase the limitation to 3GB and then, we got the
OutOfMemory error, although our server has 8GB of physical memory and only
3GB is used by SQL Server. Now we have the Maximum used memory (in
megabytes) to 2100.
Do you have any clue about why we have memory problems when there are 2GB
of physical memory available?
>
Thank you very much,
Any guidance will be appreciated.
>


Thank you very much for your help. I have the /3GB in our boot.ini file:

[boot loader]
redirect=UseBiosSettings
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOW S
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows Server 2003, Enterprise
3GB" /fastdetect /3GB /PAE /redirect /NoExecute=OptOut

Are there anything else we can do in order w3wp.exe to be able to use more
than 2 GB?

Thanks a lot.

"bruce barker (sqlwork.com)" <b_r_u_c_e_removeunderscores@.sqlwork.com>
escribi en el mensaje news:%237F$M4ZCHHA.5012@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

unless your running 64 bit or 32bit with the 3gb switch, 2gb is the max
you can set the memory to.
>
-- bruce (sqlwork.com)
>
"Carmen" <quitaresto@.cpachecoe@.fcc.es@.quitarestowrote in message
news:%23OkvY8UCHHA.5012@.TK2MSFTNGP06.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>We have an application using .NET framework 1.1 and SQL Server 2000. The
>application seems to be running very well until we get an OutOfMemory
>error. The computer has enough memory, in fact, when the error takes
>place there are 2 GB available in physical memory.
>Some days ago, we have a limitation in memory for DefaultAppPool of 1,5
>GB before recycling.This made the session information be lost quite
>often, so, we decided to increase the limitation to 3GB and then, we got
>the OutOfMemory error, although our server has 8GB of physical memory and
>only 3GB is used by SQL Server. Now we have the Maximum used memory (in
>megabytes) to 2100.
>Do you have any clue about why we have memory problems when there are 2GB
>of physical memory available?
>>
>Thank you very much,
>Any guidance will be appreciated.
>>


>
>


Are you doing any work like dynamically generating images using GDI?
If so you might want to make sure that the code cleans up after itself
correctly or your server memory will go through the roof!

On Thu, 16 Nov 2006 08:16:08 +0100, "Carmen"
<quitaresto@.cpachecoe@.fcc.es@.quitarestowrote:

Quote:

Originally Posted by

>Hi,
>
>We have an application using .NET framework 1.1 and SQL Server 2000. The
>application seems to be running very well until we get an OutOfMemory error.
>The computer has enough memory, in fact, when the error takes place there
>are 2 GB available in physical memory.
>Some days ago, we have a limitation in memory for DefaultAppPool of 1,5 GB
>before recycling.This made the session information be lost quite often, so,
>we decided to increase the limitation to 3GB and then, we got the
>OutOfMemory error, although our server has 8GB of physical memory and only
>3GB is used by SQL Server. Now we have the Maximum used memory (in
>megabytes) to 2100.
>Do you have any clue about why we have memory problems when there are 2GB of
>physical memory available?
>
>Thank you very much,
>Any guidance will be appreciated.
>


--

Bits.Bytes.
http://bytes.thinkersroom.com

Tuesday, March 13, 2012

System.Runtime.InteropServices.COMException + Unspecified Error

Hi..

I am using AD and SQL Authentication in my site. I am using ASP.NET 2.0+C#.

I have a web page, in which i can create users. While I try to create an user for the first time, I am getting anUnspecified Error. Repeated trials are successfully creating users in the database and AD, I am using the Authentication mode as:SQL_and_AD_Authentication

In my information log, I have the following stack trace:

Timestamp: 24/09/2007 14:27:32
Message: HandlingInstanceID: 272245f4-2d0a-422a-8d7d-0fdf66ad1b44
An exception of type 'System.Runtime.InteropServices.COMException' occurred and was caught.
----------------------------
09/24/2007 15:27:32
Type : System.Runtime.InteropServices.COMException, mscorlib, Version=2.0.0.0, Culture=neutral,

Message : Unspecified error

Source : App_Web_2b_1-umr
Help link :
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite : Void AddUser()
Stack Trace : at MyAdmin.UI.SiteViewAgents.AddUser()
at MyAdmin.UI.SiteViewAgents.UpdateAgent(String AgentId)

Additional Info:

MachineName : CCQASRV
TimeStamp : 24/09/2007 14:27:32
FullName : Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null

ThreadIdentity :
WindowsIdentity : BTCCOUTBOUND\Administrator

Category: Error
Priority: 0
EventId: 100
Severity: Error
Title:Enterprise Library Exception Handling
Machine: CCQASRV
Application Domain: /LM/W3SVC/1/Root/NGCCManagementFrameworkAdmin_QA2.1-1-128351114095156250
Process Id: 6196
Process Name: c:\windows\system32\inetsrv\w3wp.exe
Win32 Thread Id: 8480
Thread Name:
Extended Properties:

what is this Unspecified Error? Please help..

Thanks

Check this thread to see if it gives some pointers

http://www.eggheadcafe.com/software/aspnet/29434778/cannot-add-user-to-active.aspx

HTH,
Suprotim Agarwal

--
http://www.dotnetcurry.com
--


Hi..

Thank you very much for the reply.. But I couldn't get much help from that.

Thanks


Hi,

In that case, try posting the code which you feel causes the error.

Suprotim.


Hi venkatzeus,

According to MSDN, if the HRESULT is a custom result or if it is unknown to the runtime, the runtime passes a genericCOMException to the client. TheErrorCode property of theCOMException contains the HRESULT value. You can use catch(ComException ex) to catch this type of exception.

http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.comexception(VS.71).aspx

Hope it helps.


HI..

I searched in google and found out this:

http://support.microsoft.com/kb/232282

It says, it is a Generic COM Error Codes. How to catch these generic COM Error codes and provide more meaningful messages to the end user.

Thanks

loadTOCNode(2, 'moreinformation');