Showing posts with label select. Show all posts
Showing posts with label select. 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

Hello,

I have the following code where all the used variable are declared to their respective types:

insertSql = "SELECT Max([Customer ID]) AS CustID FROM [Registration Info]"
objCommand = New OleDbCommand(insertSql, objConn)
objConn.Open()
objDR = objCommand.ExecuteReader()

While objDR.Read()
CustID=objDR("Cust ID") '********** (1.)
End While

I am getting an error on (1.). its says "System.IndexOutOfRangeException: Cust ID" why is this happening? Can comeone help me whith this problem?

Thanks,
~sIf the code enters the while loop then tere are values within objDR so why not add a watch to this and check the value of objDr(0) and then objDR(1)

Hope that helps

Cheers
Gregor Suttie
I would say it is happening because there is no field in the result called "Cust ID", though there is one called "CustID"
Yes i know thats a silly mistake on my part. very silly... i wish i could delete this post. :) thanks very much. now i am doing it like objDR(0)

Regards.

Wednesday, March 28, 2012

system.IO.File.Exists doesnt working for file that is outside my virtual directory

hi

i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no

if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.

so how to select file from any folder on my PC and chech that it exist
or notIt may have to do with the ASP.net user in IIS not having read
permissions on the directories?

Max wrote:

Quote:

Originally Posted by

hi
>
i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no
>
if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.
>
so how to select file from any folder on my PC and chech that it exist
or not


Are you using an absolute path or a relative path to the file?

"Max" wrote:

Quote:

Originally Posted by

hi
>
i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no
>
if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.
>
so how to select file from any folder on my PC and chech that it exist
or not
>
>


followin is the error i am getting

Server Error in '/' Application.
------------------------

Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.
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.UnauthorizedAccessException: Access to the
path "L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg"
is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS
5 or Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user
(typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in
Explorer, choose "Properties" and select the Security tab. Click "Add"
to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access.

Source Error:

An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.

Stack Trace:

[UnauthorizedAccessException: Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.File.Delete(String path) +165
CMSAPPS.mas_WMKD_entry.Save_ADD() in
D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :248
CMSAPPS.mas_WMKD_entry.bttn_Save_Click(Object sender, EventArgs e)
in D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :221
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
What do you not understand about the exception's explanation?

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?

"Max" <mahesh.anjani@.gmail.comwrote in message
news:1155306880.304856.71550@.i3g2000cwc.googlegrou ps.com...

Quote:

Originally Posted by

followin is the error i am getting
>
Server Error in '/' Application.
------------------------
>
Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.
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.UnauthorizedAccessException: Access to the
path "L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg"
is denied.
>
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS
5 or Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user
(typically IUSR_MACHINENAME) or the authenticated request user.
>
To grant ASP.NET write access to a file, right-click the file in
Explorer, choose "Properties" and select the Security tab. Click "Add"
to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access.
>
Source Error:
>
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
>
>
Stack Trace:
>
>
[UnauthorizedAccessException: Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.File.Delete(String path) +165
CMSAPPS.mas_WMKD_entry.Save_ADD() in
D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :248
CMSAPPS.mas_WMKD_entry.bttn_Save_Click(Object sender, EventArgs e)
in D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :221
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
>

Monday, March 26, 2012

System.Net.Mail Address Book Access

I would like to allow our users a chance to select a MailMessage.To
destination if they want to before the email is sent. Is there a way to popu
p
the address book from OutLook? At this point, I'm assuming I'll need to use
automation to add this function.
Thanks, Stew"Stew" <Stew@.discussions.microsoft.com> wrote in message
news:682A09C4-6DE6-46AD-A04C-932011F73219@.microsoft.com...

>I would like to allow our users a chance to select a MailMessage.To
> destination if they want to before the email is sent. Is there a way to
> popup
> the address book from OutLook? At this point, I'm assuming I'll need to
> use
> automation to add this function.
Slightly curious...
Assuming this is a corporate intranet site, chances are addresses would
normally be stored in your mail server (e.g. the GAL in Exchange Server), so
you fetch them from there...
Obviously, you wouldn't even contemplate doing something like this on a
public website because of the security implications, and you'd have no way
of knowing if Outlook was installed anyway...
Can you describe your environment a bit more...?
http://www.markrae.net
yes, sorry it is an intranet site.
"Stew" <Stew@.discussions.microsoft.com> wrote in message
news:D4ED302E-5818-4F6A-8FA9-2D63883D3010@.microsoft.com...

> yes, sorry it is an intranet site.
OK, so presumably you have a network mail server to which everybody's local
Outlook connects and which contains the global set of email addresses...?
http://www.markrae.net

System.Net.Mail Address Book Access

I would like to allow our users a chance to select a MailMessage.To
destination if they want to before the email is sent. Is there a way to popup
the address book from OutLook? At this point, I'm assuming I'll need to use
automation to add this function.

Thanks, Stew"Stew" <Stew@.discussions.microsoft.comwrote in message
news:682A09C4-6DE6-46AD-A04C-932011F73219@.microsoft.com...

Quote:

Originally Posted by

>I would like to allow our users a chance to select a MailMessage.To
destination if they want to before the email is sent. Is there a way to
popup
the address book from OutLook? At this point, I'm assuming I'll need to
use
automation to add this function.


Slightly curious...

Assuming this is a corporate intranet site, chances are addresses would
normally be stored in your mail server (e.g. the GAL in Exchange Server), so
you fetch them from there...

Obviously, you wouldn't even contemplate doing something like this on a
public website because of the security implications, and you'd have no way
of knowing if Outlook was installed anyway...

Can you describe your environment a bit more...?

--
http://www.markrae.net
yes, sorry it is an intranet site.
"Stew" <Stew@.discussions.microsoft.comwrote in message
news:D4ED302E-5818-4F6A-8FA9-2D63883D3010@.microsoft.com...

Quote:

Originally Posted by

yes, sorry it is an intranet site.


OK, so presumably you have a network mail server to which everybody's local
Outlook connects and which contains the global set of email addresses...?

--
http://www.markrae.net