Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Wednesday, March 28, 2012

Trouble converting object to a string using format

Hi all,

I have an object (ie: type Object) which contains a date string like this: 28/04/2004 02:32:52 PM. (This object comes from a legacy COM dll that we use against our database so I can't change this type.)

I want to convert this Object's string to a date in a date format such as "yyyy-MM-dd" which is stored in another string (we get this from the globalisation settings as follows):

_dateFormat = new System.Globalization.CultureInfo(Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"], true).DateTimeFormat.ShortDatePattern.ToString();

So, taking my object with the long date string (remember, it is not a DateTime object) I want to convert it to another string using the format above... so I'd get a string containing "2004-04-28".

Anyone know how I can do this... it should be easy but I can't seem to get it to work.

TIA for any help...

MikeHello,
what don't u use something like this:

( (DateTime)urObject).ToShortDateString();

try it and tell me what happens.
Thanks Haidar... don't why I didn't get that first time around!

Cheers,

Mike
Glad i was able to help you out my friend.

Good Luck.

Monday, March 26, 2012

trouble executing SP, SqlDbType.Bit...

ASP.NET 2.0
This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this' I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @dotnet.itags.org.id uniqueidentifier, @dotnet.itags.org.user int, @dotnet.itags.org.type
bit
Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@dotnet.itags.org.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@dotnet.itags.org.type", SqlDbType.Bit).Value = type;
}
}
any suggetions?
JeffIt says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

> ASP.NET 2.0
> This stored procedure fails because the variable type contains a number.
> I've debugged the SP in VS2005 and it works if I change the 0/1 value of
> type to true/false... How should I fix this' I cannot just replace type
> with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
> This is header of this SP:
> ALTER PROCEDURE dbo.DeleteMessage @.id uniqueidentifier, @.user int, @.type
> bit
> Here is the ASP.NET code
> public override void DeleteMessage(System.Guid id, int user, Boolean type)
> {
> using (SqlConnection cn = new SqlConnection(this.ConnectionString))
> {
> SqlCommand cmd = new SqlCommand("SendMessage", cn);
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.Parameters.Add("@.id", SqlDbType.UniqueIdentifier).Value = id;
> cmd.Parameters.Add("@.user", SqlDbType.Int).Value = user;
> cmd.Parameters.Add("@.type", SqlDbType.Bit).Value = type;
> }
> }
> any suggetions?
> Jeff
>
>

trouble executing SP, SqlDbType.Bit...

ASP.NET 2.0

This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong

This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @dotnet.itags.org.id uniqueidentifier, @dotnet.itags.org.user int, @dotnet.itags.org.type
bit

Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@dotnet.itags.org.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@dotnet.itags.org.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@dotnet.itags.org.type", SqlDbType.Bit).Value = type;
}
}

any suggetions?

JeffIt says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Jeff" wrote:

Quote:

Originally Posted by

ASP.NET 2.0
>
This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong
>
This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessage @.id uniqueidentifier, @.user int, @.type
bit
>
Here is the ASP.NET code
public override void DeleteMessage(System.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("SendMessage", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@.id", SqlDbType.UniqueIdentifier).Value = id;
cmd.Parameters.Add("@.user", SqlDbType.Int).Value = user;
cmd.Parameters.Add("@.type", SqlDbType.Bit).Value = type;
}
}
>
any suggetions?
>
Jeff
>
>
>

Trouble Loading Code Behind Type

Hello,

I'm a new VS.NET user having the following issue.

I've created a new ASP.NET WEb Forms app and have been doing some basic
things with no real problems.

I have decided that the next thing in the development will be a secured area
of the app.

I have determined the Forms Authentication is the way I am going.

I have created a basic login form and modified the Web.config file in my
app's main virtual directory (where all of my files have hitherto resided).
I got this all working, no problem. When a page was requested, the user was
redirected to the login form as expected and when authenticated the
originally requested page was properly display.

Here is where the problem comes up. The site will be a mix of public and
"auth-required" pages. So this basically means that I do not want the
"main" virtual directory of the app secured.

Here is what I did.

First, I disabled the authentication requirement on the main virtual
directory.

Then I created a new virtual directory (under the main app's virtual
directory) and called it "Secure".

I moved the Login.aspx (my custom login form) into the Secure virutal
directory and created an additional blank page in there as well.

I put a new copy of Web.config in the Secure virtual directory and
configured it up for Forms based authentication.

Here is what I expect to happen.

When a page in the app's main virtual directory is requested it loads
for anyone (this works fine).

When a page is initially requested in the Secure virtual directory the
user should be redirected to the Login form (the redirection occurs as
expected)

Here is the problem: The Login.aspx page pops a run time error
complaining that the code behind type cannot be loaded.
Parser Error Message: Could not load type 'RPG.Login'.
The application is named "RPG"
Here is the @dotnet.itags.org.Page
<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false"
Codebehind="Login.aspx.vb" Inherits="RPG.Login"%
Note: This was not erroring out when page in question was in the app's main
virtual directory. It only occurs for pages (I have tested a "Hello World"
page in the same virtual directory with the same error.

This seems to be some sort of pathing issue, but with the .aspx file and the
.aspx.vb file in the same folder, I don't get the problem. I've tried
changing the reference in the "Inherits" attribute to things like
RPG.Secure.Login but I'm too new to the environment to understand the
Namespace.Class reference and how it is effected by the location of the
files in question.

TIADo you have a file called "RPG.dll" in the /bin folder in the web application root?
Yes. RPG/bin/RPG.dll exists.

Thursday, March 22, 2012

Trouble with Process.start in my web application...

Hello everyone,
I have a web page which needs to open files of type .pdf (adobe) and
.doc(microsoft word).
I tried something fairly simple and have been having a lot of trouble
getting it to work.
So far just started with PDF as I figured that would be the simpler of the
two. However when that didnt seem to work.. I used a simple txt file.
Here is what I am doing
Imports System.Diagnostic
Imports System.Threading
Dim mprocess as New Process
mprocess.StartInfo.FileName = "C:\temp\readme.txt"
mprocess.Start()
mprocess.WaitForInputIdle()
Thread.Sleep(1000)
What I am expecting is to see my txt file opened up. What actually happens
is..I see notepad.exe as a process in my task manager with username ASPNET
but I do not see my file opened up...
What am I missing'
Any help and sample code in this matter would be appreciated.
Thanks in advance...
..Nishaa processes started by a service, lisk asp.net do not have access to the
desktop, so they can nott open a window. you shoudl only run commandline
programs.
-- bruce (sqlwork.com)
"Nisha" <nisha.lalvani@.rogers.com> wrote in message
news:CY2dndYOFaGolT7enZ2dnUVZ_t2dnZ2d@.ro
gers.com...
> Hello everyone,
> I have a web page which needs to open files of type .pdf (adobe) and
> .doc(microsoft word).
> I tried something fairly simple and have been having a lot of trouble
> getting it to work.
> So far just started with PDF as I figured that would be the simpler of the
> two. However when that didnt seem to work.. I used a simple txt file.
> Here is what I am doing
> Imports System.Diagnostic
> Imports System.Threading
> Dim mprocess as New Process
> mprocess.StartInfo.FileName = "C:\temp\readme.txt"
> mprocess.Start()
> mprocess.WaitForInputIdle()
> Thread.Sleep(1000)
>
> What I am expecting is to see my txt file opened up. What actually happens
> is..I see notepad.exe as a process in my task manager with username ASPNET
> but I do not see my file opened up...
> What am I missing'
> Any help and sample code in this matter would be appreciated.
>
> Thanks in advance...
> ..Nisha
>
Besides Bruce's reply, Consider this:
Even you can open a "*doc" or "*.pdf" by your server app, do you really
want to open a PDF file (by Adobe Reader) on the server and have it
WaitForInputIlde? Who is going to the server room (may be located thousands
miles away from the user, or in a locked server closet/room in your company)
to read it and close it. You propbaly meant to get a PDF/doc file and send
the end user and have it open inside a web browser, rather than opeing it on
the server.
"Nisha" <nisha.lalvani@.rogers.com> wrote in message
news:CY2dndYOFaGolT7enZ2dnUVZ_t2dnZ2d@.ro
gers.com...
> Hello everyone,
> I have a web page which needs to open files of type .pdf (adobe) and
> .doc(microsoft word).
> I tried something fairly simple and have been having a lot of trouble
> getting it to work.
> So far just started with PDF as I figured that would be the simpler of the
> two. However when that didnt seem to work.. I used a simple txt file.
> Here is what I am doing
> Imports System.Diagnostic
> Imports System.Threading
> Dim mprocess as New Process
> mprocess.StartInfo.FileName = "C:\temp\readme.txt"
> mprocess.Start()
> mprocess.WaitForInputIdle()
> Thread.Sleep(1000)
>
> What I am expecting is to see my txt file opened up. What actually happens
> is..I see notepad.exe as a process in my task manager with username ASPNET
> but I do not see my file opened up...
> What am I missing'
> Any help and sample code in this matter would be appreciated.
>
> Thanks in advance...
> ..Nisha
>

Tuesday, March 13, 2012

Troubles in .cs compile with unc type oledb connections strings..

I have an .cs file I need to compile with csc.exe for codebehind
access (no VS.NET). Trouble is that my oledb connection needs to use
a unc type path.. when I use the unc path in conn I get
escape sequence errors from csc.exe.. so I tried a static
mapped drive with reversed \ / from a google I found. The
.cs compiles but the conn doesn't work.. so if I can find
a method to get unc style conn to compile, I think I would be
golden. It's a known working oledb conn used all over the place
in standard asp and aspx files.. any clues into getting the
escape sequences corrected would be appreciated.. here
is what the conn would looks like of the .cs
"Provider=Advantage OLE DB Provider; Data Source=\\server\path\dir; ServerTy
pe=ADS_REMOTE_SERVER;
TableType=ADS_CDX;FilterOptions=RESPECT_
WHEN_COUNTING;"
Thanks, BobIn a C# string, backslashes are escape characters. To escape a backslash,
escape it with a backslash.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"Bob [BVP]" <bb4@.pmount.com> wrote in message
news:uzkZyQy$EHA.1296@.TK2MSFTNGP10.phx.gbl...
> I have an .cs file I need to compile with csc.exe for codebehind
> access (no VS.NET). Trouble is that my oledb connection needs to use
> a unc type path.. when I use the unc path in conn I get
> escape sequence errors from csc.exe.. so I tried a static
> mapped drive with reversed \ / from a google I found. The
> .cs compiles but the conn doesn't work.. so if I can find
> a method to get unc style conn to compile, I think I would be
> golden. It's a known working oledb conn used all over the place
> in standard asp and aspx files.. any clues into getting the
> escape sequences corrected would be appreciated.. here
> is what the conn would looks like of the .cs
> "Provider=Advantage OLE DB Provider; Data Source=\\server\path\dir;
> ServerType=ADS_REMOTE_SERVER;
> TableType=ADS_CDX;FilterOptions=RESPECT_
WHEN_COUNTING;"
> Thanks, Bob
>
Thanks.. If I have \\server\share it would be \\\\server\\share ?
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:udIvrMz$EHA.2196@.TK2MSFTNGP14.phx.gbl...
> In a C# string, backslashes are escape characters. To escape a backslash,
> escape it with a backslash.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Neither a follower nor a lender be.
> "Bob [BVP]" <bb4@.pmount.com> wrote in message
> news:uzkZyQy$EHA.1296@.TK2MSFTNGP10.phx.gbl...
>

Troubles in .cs compile with unc type oledb connections strings..

I have an .cs file I need to compile with csc.exe for codebehind
access (no VS.NET). Trouble is that my oledb connection needs to use
a unc type path.. when I use the unc path in conn I get
escape sequence errors from csc.exe.. so I tried a static
mapped drive with reversed \ / from a google I found. The
..cs compiles but the conn doesn't work.. so if I can find
a method to get unc style conn to compile, I think I would be
golden. It's a known working oledb conn used all over the place
in standard asp and aspx files.. any clues into getting the
escape sequences corrected would be appreciated.. here
is what the conn would looks like of the .cs

"Provider=Advantage OLE DB Provider; Data Source=\\server\path\dir; ServerType=ADS_REMOTE_SERVER;
TableType=ADS_CDX;FilterOptions=RESPECT_WHEN_COUNT ING;"

Thanks, BobIn a C# string, backslashes are escape characters. To escape a backslash,
escape it with a backslash.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Bob [BVP]" <bb4@.pmount.com> wrote in message
news:uzkZyQy$EHA.1296@.TK2MSFTNGP10.phx.gbl...
> I have an .cs file I need to compile with csc.exe for codebehind
> access (no VS.NET). Trouble is that my oledb connection needs to use
> a unc type path.. when I use the unc path in conn I get
> escape sequence errors from csc.exe.. so I tried a static
> mapped drive with reversed \ / from a google I found. The
> .cs compiles but the conn doesn't work.. so if I can find
> a method to get unc style conn to compile, I think I would be
> golden. It's a known working oledb conn used all over the place
> in standard asp and aspx files.. any clues into getting the
> escape sequences corrected would be appreciated.. here
> is what the conn would looks like of the .cs
> "Provider=Advantage OLE DB Provider; Data Source=\\server\path\dir;
> ServerType=ADS_REMOTE_SERVER;
> TableType=ADS_CDX;FilterOptions=RESPECT_WHEN_COUNT ING;"
> Thanks, Bob
Thanks.. If I have \\server\share it would be \\\\server\\share ?

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:udIvrMz$EHA.2196@.TK2MSFTNGP14.phx.gbl...
> In a C# string, backslashes are escape characters. To escape a backslash,
> escape it with a backslash.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Neither a follower nor a lender be.
> "Bob [BVP]" <bb4@.pmount.com> wrote in message
> news:uzkZyQy$EHA.1296@.TK2MSFTNGP10.phx.gbl...
> > I have an .cs file I need to compile with csc.exe for codebehind
> > access (no VS.NET). Trouble is that my oledb connection needs to use
> > a unc type path.. when I use the unc path in conn I get
> > escape sequence errors from csc.exe.. so I tried a static
> > mapped drive with reversed \ / from a google I found. The
> > .cs compiles but the conn doesn't work.. so if I can find
> > a method to get unc style conn to compile, I think I would be
> > golden. It's a known working oledb conn used all over the place
> > in standard asp and aspx files.. any clues into getting the
> > escape sequences corrected would be appreciated.. here
> > is what the conn would looks like of the .cs
> > "Provider=Advantage OLE DB Provider; Data Source=\\server\path\dir;
> > ServerType=ADS_REMOTE_SERVER;
> > TableType=ADS_CDX;FilterOptions=RESPECT_WHEN_COUNT ING;"
> > Thanks, Bob