Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Wednesday, March 28, 2012

Trouble accessing .NET 2.0 Membership stuff from HTTP Module

I am trying to create an HTTP module to run on ASP.NET 2.0. The module needs
to check to see if the user is authenticated with the .net 2.0 membership
stuff. I am trying this:

If application.Context.User.Identity.IsAuthenticated Then
app.Context.Response.Write("user authenticated")
End If

I get a "Object Reference not set to an instance of anobject." error on
application.Context.User.Identity.IsAuthenticated.

I am always getting an error. Does anyone have any suggestions? Do I need
to configure anything special for the module? Thanks.You should look into handling the PostAuthenticateRequest event instead.
That way you don't have ordering issues with the other modules during the
AuthenticateRequest event.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> I am trying to create an HTTP module to run on ASP.NET 2.0. The
> module needs to check to see if the user is authenticated with the
> .net 2.0 membership stuff. I am trying this:
> If application.Context.User.Identity.IsAuthenticated Then
> app.Context.Response.Write("user authenticated")
> End If
> I get a "Object Reference not set to an instance of anobject." error
> on application.Context.User.Identity.IsAuthenticated.
> I am always getting an error. Does anyone have any suggestions? Do I
> need to configure anything special for the module? Thanks.
Thanks. That fixed it.

"Brock Allen" wrote:

> You should look into handling the PostAuthenticateRequest event instead.
> That way you don't have ordering issues with the other modules during the
> AuthenticateRequest event.
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
> > I am trying to create an HTTP module to run on ASP.NET 2.0. The
> > module needs to check to see if the user is authenticated with the
> > .net 2.0 membership stuff. I am trying this:
> > If application.Context.User.Identity.IsAuthenticated Then
> > app.Context.Response.Write("user authenticated")
> > End If
> > I get a "Object Reference not set to an instance of anobject." error
> > on application.Context.User.Identity.IsAuthenticated.
> > I am always getting an error. Does anyone have any suggestions? Do I
> > need to configure anything special for the module? Thanks.
>
>

trouble creating a zodiac sign web service...

I would like to create a web service that returns the zodiac sign of a given date.

The problem I am having is that I have no idea how to do the following:

I receive a DateTime object with the date as a ShortDateFormat (e.g. 3/1/2005), and I would like to compare this to make sure it falls within a range of dates (compare it to a date range of February 20- March 20 for example) and it returns true. At which point I return the String "Pisces."

Any help on how to do this is greatly appreciated. The problem I don't understand is how to compare a date to a date range and see if it falls within it or not!

Thanks in advance
~nK~

p.s. sorry if this is in the wrong section but I posted in XML Web Services as well :)Hi,
As far as I know there is no scalar to range comparison. Use simple search algorithm to locate relevant range. You can sort your zodiac date ranges by starting date, compare your input date to starting date, until you find first starting date greater then input date, use previous range.
yea or convert all the days to a numeric day of the year (0-364(5) or 1-365(6)), then set numeric ranges for all the zodiac signs (100-131 = pices for example), then you can convert the entered date to a number and tell where it "fits in" to the zodiac ranges.
I created the service using a select statement on the month part alone.

Then each case is for each month, and then it has an if to say whether it is less than or equal to a specific day at which point it returns the correct zodiac sign.

For example, if I put in the date 3/1/05 it should return Pisces.

Select Month(dateObj)
Case 3
If Day(dateObj) <=21 Then
return "Pisces"
Else: Return "Aries"

and so on...

Of course the dateObj is the date that is returned.

Now I am trying to make the date not be cultural specific. Any ideas how this is done?
Basically, in some parts of the world they enter the date as dd/mm/yy but in other parts its mm/dd/yy. So that's what I meant by not cultural specific.

Thanks.
~nK~

Trouble creating new directory

Hello,
I am using c# and running a site that is on a shared
host. The code in question is supposed to create a new
directory that is coming out of a text box.

It works fine on my computer, but I get the following
stack trace:

System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\". at System.IO.__Error.WinIOError
(Int32 errorCode, String str) at
System.IO.Directory.InternalCreateDirectory(String
fullPath, String path) at System.IO.DirectoryInfo.Create
() at testapps.createdir.CreateSubDirectory(String direc)

The code to create is as follows:

public bool CreateSubDirectory(string direc)
{
bool returnStatus = false;
DirectoryInfo di = new DirectoryInfo(@dotnet.itags.org.direc);
if(di.Exists)
{
Trace.Write("Directory exists " +
di.FullName);
this.Label1.Text = "Directory exists";
}
else
{
Trace.Write("Directory does not exist " +
di.FullName);
this.Label1.Text = "Directory does not
exists";
try
{
di.Create();
if(di.Exists)
{
Trace.Write("Directory exists
after creating it");
this.Label1.Text += "Directory
exists after creating it";
}
}
catch(Exception ex)
{
this.Label1.Text += "Error trying to
create directory that did not exist " + ex.ToString();
Trace.Write("Error creating directory
that does not exist " + ex);
}
}
return returnStatus;
}

Any ideas or suggestions, it works great on my local
machine?

Sheldon Cohen
shelman2@dotnet.itags.org.hotmail.comThis may be a misnomer of an error, but I think the root of your problem (no
pun intended) is that you don't have permissions to get at data outside of
your configured directory on the Host server. Imagine if you could - you can
probe the entire server and scavage all the other site's files which would
be a bit of a security risk to say the least.

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
-----------
Making waves on the Web

"Sheldon Cohen" <shelman2@.hotmail.com> wrote in message
news:2db7501c394e2$8cb6dd20$a601280a@.phx.gbl...
> Hello,
> I am using c# and running a site that is on a shared
> host. The code in question is supposed to create a new
> directory that is coming out of a text box.
> It works fine on my computer, but I get the following
> stack trace:
> System.IO.DirectoryNotFoundException: Could not find a
> part of the path "D:\". at System.IO.__Error.WinIOError
> (Int32 errorCode, String str) at
> System.IO.Directory.InternalCreateDirectory(String
> fullPath, String path) at System.IO.DirectoryInfo.Create
> () at testapps.createdir.CreateSubDirectory(String direc)
> The code to create is as follows:
> public bool CreateSubDirectory(string direc)
> {
> bool returnStatus = false;
> DirectoryInfo di = new DirectoryInfo(@.direc);
> if(di.Exists)
> {
> Trace.Write("Directory exists " +
> di.FullName);
> this.Label1.Text = "Directory exists";
> }
> else
> {
> Trace.Write("Directory does not exist " +
> di.FullName);
> this.Label1.Text = "Directory does not
> exists";
> try
> {
> di.Create();
> if(di.Exists)
> {
> Trace.Write("Directory exists
> after creating it");
> this.Label1.Text += "Directory
> exists after creating it";
> }
> }
> catch(Exception ex)
> {
> this.Label1.Text += "Error trying to
> create directory that did not exist " + ex.ToString();
> Trace.Write("Error creating directory
> that does not exist " + ex);
> }
> }
> return returnStatus;
> }
> Any ideas or suggestions, it works great on my local
> machine?
> Sheldon Cohen
> shelman2@.hotmail.com
Thanks, that makes sense. I have contacted my host and they do not have
a clue what to do. Any suggestions of how I could get this working?

Thanks,

Sheldon Cohen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Thanks, that makes sense. I have contacted my host and they do not have
a clue what to do. Any suggestions of how I could get this working?

Thanks,

Sheldon Cohen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
What do you need access to the root for?

Basically your domain probably runs under a specific user account they've
set up for you. That username needs rights to access the directories you
want to access. Since htey lock it down they should have a clue what to do
<g>...

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
-----------
Making waves on the Web

"Sheldon Cohen" <shelman2@.hotmail.com> wrote in message
news:uMQNpQSlDHA.3504@.TK2MSFTNGP11.phx.gbl...
> Thanks, that makes sense. I have contacted my host and they do not have
> a clue what to do. Any suggestions of how I could get this working?
> Thanks,
> Sheldon Cohen
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
What do you need access to the root for?

Basically your domain probably runs under a specific user account they've
set up for you. That username needs rights to access the directories you
want to access. Since htey lock it down they should have a clue what to do
<g>...

+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
-----------
Making waves on the Web

"Sheldon Cohen" <shelman2@.hotmail.com> wrote in message
news:uMQNpQSlDHA.3504@.TK2MSFTNGP11.phx.gbl...
> Thanks, that makes sense. I have contacted my host and they do not have
> a clue what to do. Any suggestions of how I could get this working?
> Thanks,
> Sheldon Cohen
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Hi, thanks for responding back to my message.

I don't need root access I think, I am just trying to create a new
directory for each new user that matches a username they choose while
signing up from our website. We create a new jad file which is for their
java enabled cell phone. We are able to create the file using
StreamWriter and File.Create(), only the directory is giving us trouble.

The hosting company is not sure when we called them, they said they were
researching it. I have tried to use the
\\SERVER\OURUSERACCOUNTNAME\DIRECTORY but that gives us the message:
System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\". at System.IO.__Error.WinIOError
(Int32 errorCode, String str) at
System.IO.Directory.InternalCreateDirectory(String
fullPath, String path) at System.IO.DirectoryInfo.Create
() at testapps.createdir.CreateSubDirectory(String direc)

We are really not sure what to do next. Seems like the
d:\inetput\wwwroot\OURUSERACCOUNTNAME\wwwRoot\jads which works when we
use the File.Create(PATH) does not work here.

Thanks for all the help so far, any more would be great.

Sheldon Cohen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Hi, thanks for responding back to my message.

I don't need root access I think, I am just trying to create a new
directory for each new user that matches a username they choose while
signing up from our website. We create a new jad file which is for their
java enabled cell phone. We are able to create the file using
StreamWriter and File.Create(), only the directory is giving us trouble.

The hosting company is not sure when we called them, they said they were
researching it. I have tried to use the
\\SERVER\OURUSERACCOUNTNAME\DIRECTORY but that gives us the message:
System.IO.DirectoryNotFoundException: Could not find a
part of the path "D:\". at System.IO.__Error.WinIOError
(Int32 errorCode, String str) at
System.IO.Directory.InternalCreateDirectory(String
fullPath, String path) at System.IO.DirectoryInfo.Create
() at testapps.createdir.CreateSubDirectory(String direc)

We are really not sure what to do next. Seems like the
d:\inetput\wwwroot\OURUSERACCOUNTNAME\wwwRoot\jads which works when we
use the File.Create(PATH) does not work here.

Thanks for all the help so far, any more would be great.

Sheldon Cohen

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I think the problem may be share permissions. I had this problem once myself
where the root directory required directory read access or else shares
weren't accessible. I can't remember the details now exactly, but ultimately
it ended up being that I added EveryOne with directory read rights on the
root dir...

Bummer that htis is at an ISP which will make experimenting and trying to
find this issue a lot more work than if you can try it yourself <g
+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
-----------
Making waves on the Web

"Sheldon Cohen" <shelman2@.hotmail.com> wrote in message
news:ezyH6tylDHA.2652@.TK2MSFTNGP09.phx.gbl...
> Hi, thanks for responding back to my message.
> I don't need root access I think, I am just trying to create a new
> directory for each new user that matches a username they choose while
> signing up from our website. We create a new jad file which is for their
> java enabled cell phone. We are able to create the file using
> StreamWriter and File.Create(), only the directory is giving us trouble.
> The hosting company is not sure when we called them, they said they were
> researching it. I have tried to use the
> \\SERVER\OURUSERACCOUNTNAME\DIRECTORY but that gives us the message:
> System.IO.DirectoryNotFoundException: Could not find a
> part of the path "D:\". at System.IO.__Error.WinIOError
> (Int32 errorCode, String str) at
> System.IO.Directory.InternalCreateDirectory(String
> fullPath, String path) at System.IO.DirectoryInfo.Create
> () at testapps.createdir.CreateSubDirectory(String direc)
> We are really not sure what to do next. Seems like the
> d:\inetput\wwwroot\OURUSERACCOUNTNAME\wwwRoot\jads which works when we
> use the File.Create(PATH) does not work here.
> Thanks for all the help so far, any more would be great.
> Sheldon Cohen
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
I think the problem may be share permissions. I had this problem once myself
where the root directory required directory read access or else shares
weren't accessible. I can't remember the details now exactly, but ultimately
it ended up being that I added EveryOne with directory read rights on the
root dir...

Bummer that htis is at an ISP which will make experimenting and trying to
find this issue a lot more work than if you can try it yourself <g
+++ Rick --

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/wwHelp
-----------
Making waves on the Web

"Sheldon Cohen" <shelman2@.hotmail.com> wrote in message
news:ezyH6tylDHA.2652@.TK2MSFTNGP09.phx.gbl...
> Hi, thanks for responding back to my message.
> I don't need root access I think, I am just trying to create a new
> directory for each new user that matches a username they choose while
> signing up from our website. We create a new jad file which is for their
> java enabled cell phone. We are able to create the file using
> StreamWriter and File.Create(), only the directory is giving us trouble.
> The hosting company is not sure when we called them, they said they were
> researching it. I have tried to use the
> \\SERVER\OURUSERACCOUNTNAME\DIRECTORY but that gives us the message:
> System.IO.DirectoryNotFoundException: Could not find a
> part of the path "D:\". at System.IO.__Error.WinIOError
> (Int32 errorCode, String str) at
> System.IO.Directory.InternalCreateDirectory(String
> fullPath, String path) at System.IO.DirectoryInfo.Create
> () at testapps.createdir.CreateSubDirectory(String direc)
> We are really not sure what to do next. Seems like the
> d:\inetput\wwwroot\OURUSERACCOUNTNAME\wwwRoot\jads which works when we
> use the File.Create(PATH) does not work here.
> Thanks for all the help so far, any more would be great.
> Sheldon Cohen
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

Trouble creating an array of a class I created

What am I doing wrong? I made a class and want to create an array of that class and I keep getting "object reference not set ot an instance of an object" when the code hits line 4. Tile is the class I made

1private void usrTurnTile_Load(object sender, EventArgs e)2{3Tile[] objTile =new Tile[20];4objTile[3].Visible =false;5}

adding this fixed it...

for (int i23 = 0; i23 < 20; i23++)

objTile[i23] =newTile();


adding this fixed it...

for (int i23 = 0; i23 < 20; i23++)

objTile[i23] =newTile();


adding this fixed it...

for (int i23 = 0; i23 < 20; i23++)

objTile[i23] =newTile();

Trouble creating New Project on localhost...

I want to create a new ASP.Net project on this path in Visual
Basic.Net:

"http://localhost/WEB3.Theorie"

I configured the 'WEB3.theorie' folder so that my ASP.Net account can
access it...
But I always get the same error >
-- http/1.1 500 Internal Server Error --

I still don't see what I've done wrong, but this IIS-stuff is rather
complex for me...
I know this could be a noobie situation, but I have to start
somewhere...

..mishcozii-sanI am having this exact same problem right now, but I am still waiting for a
solution. I am using Visual Studio 2005 vb Standard with IIS 5.1.

".mishcozii" wrote:

> I want to create a new ASP.Net project on this path in Visual
> Basic.Net:
> "http://localhost/WEB3.Theorie"
> I configured the 'WEB3.theorie' folder so that my ASP.Net account can
> access it...
> But I always get the same error >>
> -- http/1.1 500 Internal Server Error --
> I still don't see what I've done wrong, but this IIS-stuff is rather
> complex for me...
> I know this could be a noobie situation, but I have to start
> somewhere...
> ..mishcozii-san
>

Trouble creating New Project on localhost...

I want to create a new ASP.Net project on this path in Visual
Basic.Net:
"http://localhost/WEB3.Theorie"
I configured the 'WEB3.theorie' folder so that my ASP.Net account can
access it...
But I always get the same error >>
-- http/1.1 500 Internal Server Error --
I still don't see what I've done wrong, but this IIS-stuff is rather
complex for me...
I know this could be a noobie situation, but I have to start
somewhere...
.mishcozii-sanI am having this exact same problem right now, but I am still waiting for a
solution. I am using Visual Studio 2005 vb Standard with IIS 5.1.
".mishcozii" wrote:

> I want to create a new ASP.Net project on this path in Visual
> Basic.Net:
> "http://localhost/WEB3.Theorie"
> I configured the 'WEB3.theorie' folder so that my ASP.Net account can
> access it...
> But I always get the same error >>
> -- http/1.1 500 Internal Server Error --
> I still don't see what I've done wrong, but this IIS-stuff is rather
> complex for me...
> I know this could be a noobie situation, but I have to start
> somewhere...
> ..mishcozii-san
>

Monday, March 26, 2012

Trouble getting an "Update Quantities" Button Working

Hello,

I am trying to create a click handler on an update quantities button which updates the quantities with the textbox. I am using a datalist and have addressed the "ProductID" as the DataKeyField. Can someone please help me code this?

This is the code
--------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
Dim productID As String = Request.Params("AddToCart" )
If Not productID Is Nothing Then
Dim cart As New ShoppingCart()
cart.AddProduct(productID)
End If
BindShoppingCart()
checkoutCodeLabel.Text = "Checkout Code: "
End If
End Sub

Private Sub BindShoppingCart()
Dim cart As New ShoppingCart()
list.DataSource = cart.GetProducts
list.DataKeyField = "ProductID"
list.DataBind()

If cart.GetTotalAmount = 0 Then
placeOrderButton.Enabled = False
Else
placeOrderButton.Enabled = True
End If

TotalAmount.Text = "Total amount:"

totalAmountLabel.Text = String.Format("{0:c}", cart.GetTotalAmount())
End Sub

Private Sub btnUpdateQuantity_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateQuantity.Click
(WHAT DO I PUT HERE??????????)
End Sub

Thanks in advance!Where you can get the total after you click the update button and page post back? looks like all the code in page_load will not run for they are in "If Not Page.IsPostBack ".

Trouble on creating a new web project - UNC share does not exist or you do not have access

Hello,

While I tried to create a new web project in VS.NET, I got the following
error message:
"Unable to create Web project 'Portal'. The UNC share
'E:\Project\Portal\Src\Web' does not exist or you do not have access."

My server's OS is Windows 2000 Server. My steps are:
In IIS:
1. create a virtual directory 'Portal'. Its local directory is
'E:\Project\Portal\Src\Web'.

In VS.NET:
2. in 'Add New Project' dialog box, select the followings and click 'OK'
button.
Project Types: Visual C# Projects
Templates: New Project In Existing Folder
Name: Portal

3. in 'Create a New Project in an Existing Folder' dialog box, input the
following and click 'OK' button.
Folder location: http://localhost/Portal

4. And then, VS.NET tell me the error message:
"Unable to create Web project 'Portal'. The UNC share
'E:\Project\Portal\Src\Web' does not exist or you do not have access."

Can you help me to resolve the problem? I have tried for many days.

Thank you very much,
SimonFrom your description, this seems to be the problem:
http://support.microsoft.com/defaul...kb;en-us;320265

Cheers
Ken

"Simon Chung-Jen Chuang" <cjchuang98@.seed.net.tw> wrote in message
news:%23$y8W$VaDHA.4020@.tk2msftngp13.phx.gbl...
: Hello,
:
: While I tried to create a new web project in VS.NET, I got the following
: error message:
: "Unable to create Web project 'Portal'. The UNC share
: 'E:\Project\Portal\Src\Web' does not exist or you do not have access."
:
: My server's OS is Windows 2000 Server. My steps are:
: In IIS:
: 1. create a virtual directory 'Portal'. Its local directory is
: 'E:\Project\Portal\Src\Web'.
:
: In VS.NET:
: 2. in 'Add New Project' dialog box, select the followings and click 'OK'
: button.
: Project Types: Visual C# Projects
: Templates: New Project In Existing Folder
: Name: Portal
:
: 3. in 'Create a New Project in an Existing Folder' dialog box, input the
: following and click 'OK' button.
: Folder location: http://localhost/Portal
:
: 4. And then, VS.NET tell me the error message:
: "Unable to create Web project 'Portal'. The UNC share
: 'E:\Project\Portal\Src\Web' does not exist or you do not have access."
:
: Can you help me to resolve the problem? I have tried for many days.

Thursday, March 22, 2012

trouble with passing date to stored procedure

Trying to create a app that will read through our log files. I am reading through a directory and for each file I loop line by line and split the log into an array by SPACE and then send the IP, name of the log file, referer URL, and datetime to a stored procedure (below). The following code just returns 0 as a result and is not true. I believe my issue is in the asp.net datetime vs the datetime format in my database.

The datetime sent to the SP is: 10/17/2004 12:00:19 AM
The datetime in the field DT_TM I am comparing to is: 2004-06-23 10:17:23.000

Just hoping someone has a good grasp on this datetime format issue since I am clueless at this point on what to do. Cause I was sending in without converting to a date and kept getting errors.

This section of code is a portion taken from my .aspx file


'----
Dim dtLogDateTime as DateTime
adoCon = New SqlConnection("Server=xx.xx.xx.xx;Database=dbname;Uid=user;Pwd=pwd")
cmdSQL = New SqlCommand("sc_add_referer", adoCon)
cmdSQL.CommandType = CommandType.StoredProcedure

'Input Parameters
cmdSQL.Parameters.Add("@dotnet.itags.org.SENT_IP", arrArray2(5))
cmdSQL.Parameters.Add("@dotnet.itags.org.SENT_LOG_FILE", arFile(arFile.Length -1))
cmdSQL.Parameters.Add("@dotnet.itags.org.SENT_REFERER", arrArray2(8))
dtLogDateTime = arrArray2(0) & " " & arrArray2(1)
cmdSQL.Parameters.Add("@dotnet.itags.org.SENT_DT_TM", dtLogDateTime)

'Output parameter
parmSQL = cmdSQL.Parameters.Add("ReturnValue", SqlDbType.Int)
parmSQL.Direction = ParameterDirection.ReturnValue

adoCon.Open()
cmdSQL.ExecuteNonQuery()
iReturnVal = cmdSQL.Parameters("ReturnValue").Value

If iReturnVal = -2 Then
Response.Write("<br>" & arrArray2(3) & " " & arrArray2(5))
End if
adoCon.Close()
'----

The following is the SQL Server stored procedure I am calling


CREATE PROCEDURE sc_add_referer
(
@dotnet.itags.org.SENT_IP varchar(15),
@dotnet.itags.org.SENT_LOG_FILE varchar(15),
@dotnet.itags.org.SENT_REFERER text,
@dotnet.itags.org.SENT_DT_TM datetime
)
AS
DECLARE @dotnet.itags.org.ROW_CNT INT
DECLARE @dotnet.itags.org.ROW_ORDERID INT
DECLARE @dotnet.itags.org.ROW_DT_TM INT
DECLARE @dotnet.itags.org.SUB_CNT INT

--FIRST NEED TO FIND OUT IF IN MAIN TABLE
SELECT @dotnet.itags.org.ROW_CNT = count(*), @dotnet.itags.org.ROW_ORDERID = ORDER_ID
FROM sc_ip_tracking
WHERE IP = @dotnet.itags.org.SENT_IP
GROUP BY ORDER_ID

SELECT @dotnet.itags.org.SUB_CNT = count(*)
FROM sc_ip_tracking_referers
WHERE ORDER_ID = @dotnet.itags.org.ROW_ORDERID
AND LOG_FILE = @dotnet.itags.org.SENT_LOG_FILE

IF @dotnet.itags.org.ROW_CNT > 0
-- IP FOUND SO SEE IF FOUND IN REFERER LOG
IF @dotnet.itags.org.SUB_CNT > 0
--ROW ROUND
RETURN 0
ELSE
-- NO ROW FOUND SO NEED TO ADD INFO
BEGIN
SELECT @dotnet.itags.org.ROW_DT_TM = datediff(hour, @dotnet.itags.org.SENT_DT_TM, DT_TM) FROM sc_ip_tracking WHERE IP = @dotnet.itags.org.SENT_IP AND ORDER_ID = @dotnet.itags.org.ROW_ORDERID

IF @dotnet.itags.org.ROW_DT_TM >= 0 AND @dotnet.itags.org.ROW_DT_TM <= 8
BEGIN
INSERT INTO sc_ip_tracking_referers (ORDER_ID, LOG_FILE, REFERER, LAST_CHANGE_DT)
values (@dotnet.itags.org.ROW_ORDERID, @dotnet.itags.org.SENT_LOG_FILE, @dotnet.itags.org.SENT_REFERER, getdate())
END
RETURN -2
END
ELSE
RETURN 0
GO

Replace the "/" in the date with "-" and drop the " AM" at the end of the string. You should be good to go.

Trouble with Sample Code

Can anyone please help me out ??

I am totally new to ASP.NET.

I learnt the basics of asp (enough to create my own interactive web site) by using the asp for dummies book. In that book is some sample code called classy classifieds. This is a sample classified ads site where you can post ads and search the access database provided. By chopping this code up and customising it I learnt asp.

I am now attempting to do the same thing with the new classy classifieds data provided in ASP.NET for dummies. I am having trouble right at the start with the code provided. When I try to place a new add I get the following error message.

If I edit an existing ad, it updates to the database OK. The editad.aspx file is used for processing new ad as well as any updates to existing ones.

Could anyone please help me with this error.

PS If you need more info than the error message, please let me know and I could email the sample code files.

Many Thanks in advance !!!

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

Syntax error in INSERT INTO statement.
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.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.

Source Error:

Line 74: Row.Item("Posted") = CDate(Today)
Line 75: ClassyDS.Tables("Ads").Rows.Add(Row)
Line 76: Adapter.Update(ClassyDS, "Ads")
Line 77: PostErrors
Line 78: End Sub

Source File: C:\Inetpub\wwwroot\classy\classyad.ascx Line: 76

Stack Trace:

[OleDbException (0x80040e14): Syntax error in INSERT INTO statement.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +1534
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable) +152
ASP.ClassyAd_ascx.PlaceAd() in C:\Inetpub\wwwroot\classy\classyad.ascx:76
ASP.EditAd_aspx.Submit_Click(Object Sender, EventArgs E) in C:\Inetpub\wwwroot\classy\editad.aspx:80
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +83
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1263

------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0The problem is with the SQL statement that does the actual insert. Please post the actual SQL that the method is using. Thanks.
Thanks Nabil for helping with this !!

This is the code from my editad.aspx file, with me being new to ASP.NET I am not sure how it is trying to insert the data into the access tables. As I mentioned before, with asp I recognised the sql select and insert statements.

If you need any more info please let me know.

PS The editad.aspx file is used for entering new and also editing existing entries. It is when I try to enter a completely new record in the table that I got the original error, if you edit an existing entry, it enters the new data fine !!, thats why I thought any sql statements must be OK, anyway, Im only a beginner !!

Thanks again for your time on this.

EditAd.aspx


<%@. Page Explicit="True" Language="VB" Debug="True" %>
<%@. Register TagPrefix="ASPFD" TagName="Header" src="http://pics.10026.com/?src=header.ascx" %>
<%@. Register TagPrefix="ASPFD" TagName="ClassyAd" src="http://pics.10026.com/?src=classyad.ascx" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.OleDb" %>
<script runat="server"
Dim AdNumSent As Integer
Dim Operation As String
Dim CatListIndex As Integer

Sub Page_Load(Sender As Object, E As EventArgs)

If Not IsPostBack Then

If Trim(Request.QueryString("AdNum")) = "" Then
Operation = "PLACE"
Header.AddPageName("Place Ad")
Submit.Text = "Place Ad"

AdNumSent = 0
Else
Operation = "EDIT"
Header.AddPageName("Edit Ad")
Submit.Text = "Make Changes"

' If you make a control invisible
' you MUST also make the validation
' control(s) that refer to it
' invisible, too (not just disabled)
PasswordRequired.Visible = False
PasswordText.Visible = False
PasswordLabel.Visible = False

AdNumSent = Request.QueryString("AdNum")

ClassyAd.GetAd(AdNumSent)

TitleText.Text = ClassyAd.Title
DescriptionText.Text = ClassyAd.Description
For CatListIndex=0 To CategoryDropDown.Items.Count -1
If CategoryDropDown.Items(CatListIndex).Value = ClassyAd.Category Then
CategoryDropDown.Items(CatListIndex).Selected = True
End If
Next
PriceText.Text = ClassyAd.Price
PhoneText.Text = ClassyAd.Phone
EmailText.Text = ClassyAd.Email
StateText.Text = ClassyAd.State

End If

ViewState("Operation")=Operation
ViewState("AdNumSent")=AdNumSent
End If

End Sub

Sub Submit_Click(Sender As Object, E As EventArgs)

Operation=ViewState("Operation")
AdNumSent = ViewState("AdNumSent")

ClassyAd.GetAd(AdNumSent)

ClassyAd.Title = TitleText.Text
ClassyAd.Description = DescriptionText.Text
ClassyAd.Category = CategoryDropDown.SelectedItem.Value
ClassyAd.Price = PriceText.Text
ClassyAd.Phone = PhoneText.Text
ClassyAd.Email = EmailText.Text
ClassyAd.State = StateText.Text

If Operation="PLACE" Then
ClassyAd.Password = PasswordText.Text
ClassyAd.Posted = Today
ClassyAd.PlaceAd
Else
ClassyAd.EditAd
End If

If ClassyAd.HasErrors Then
Message.Text = "There was a database error: " & _
ClassyAd.RowError
Else
If Operation="PLACE"
Message.Text = "Your classified ad has been placed"
Else
Message.Text = "Your classified ad changes have been made"
End If
TitleText.Enabled=False
DescriptionText.Enabled=False
CategoryDropDown.Enabled=False
PriceText.Enabled=False
PhoneText.Enabled=False
EmailText.Enabled=False
StateText.Enabled=False
PasswordText.Enabled=False
Submit.Enabled=False
End If
End Sub

</script>
<html>
<head>
</head>
<body vlink="red">
<form runat="server">
<aspfd:header id="Header" runat="server"></aspfd:header>
<aspfd:classyad id="ClassyAd" runat="server" visible="false"></aspfd:classyad>
<% If Operation="PLACE" Then %>
<p>
Please fill inall of these textboxes below. Be careful when entering a Password
and be sure to remember what you type. You may be required to enter the password later
to identify yourself if you need to edit or delete this ad.
</p>
<p>
When you are finished, click the Place Ad button.
</p>
<% Else %>
<p>
Edit any of the information you like. Make sure each textbox has a valid value before
you click the Make Changes button.
</p>
<% End If %>
<table>
<tbody>
<tr>
<td>
Title:</td>
<td>
<asp:requiredfieldvalidator id="TitleRequired" runat="server" errormessage="*" controltovalidate="TitleText"></asp:requiredfieldvalidator>
<asp:textbox id="TitleText" runat="server" columns="50"></asp:textbox>
</td>
</tr>
<tr>
<td valign="top">
Description:</td>
<td>
<asp:requiredfieldvalidator id="DescriptionRequired" runat="server" errormessage="*" controltovalidate="DescriptionText"></asp:requiredfieldvalidator>
<asp:textbox id="DescriptionText" runat="server" columns="40" rows="3" textmode="multiline"></asp:textbox>
</td>
</tr>
<tr>
<td>
Category:</td>
<td>
<asp:requiredfieldvalidator id="CategoryRequired" runat="server" errormessage="*" controltovalidate="CategoryDropDown" initialvalue="* Pick a Category *"></asp:requiredfieldvalidator>
<asp:dropdownlist id="CategoryDropDown" runat="server">
<asp:listitem >* Pick a Category *</asp:listitem>
<asp:listitem value="VEHICLES">Vehicles</asp:listitem>
<asp:listitem value="COMPUTERS">Computers</asp:listitem>
<asp:listitem value="REALESTATE">Real Estate</asp:listitem>
<asp:listitem value="COLLECTIBLES">Collectibles</asp:listitem>
<asp:listitem value="GENERAL">General Merchandise</asp:listitem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td>
Price:</td>
<td>
<asp:requiredfieldvalidator id="PriceRequired" runat="server" errormessage="*" controltovalidate="PriceText"></asp:requiredfieldvalidator>
$
<asp:textbox id="PriceText" runat="server" columns="10"></asp:textbox>
</td>
</tr>
<tr>
<td>
Phone</td>
<td>
<asp:requiredfieldvalidator id="PhoneRequired" runat="server" errormessage="*" controltovalidate="PhoneText"></asp:requiredfieldvalidator>
<asp:textbox id="PhoneText" runat="server" columns="15"></asp:textbox>
</td>
</tr>
<tr>
<td>
Email:</td>
<td>
<asp:requiredfieldvalidator id="EmailRequired" runat="server" errormessage="*" controltovalidate="EmailText"></asp:requiredfieldvalidator>
<asp:textbox id="EmailText" runat="server" columns="50"></asp:textbox>
</td>
</tr>
<tr>
<td>
State:</td>
<td>
<asp:requiredfieldvalidator id="StateRequired" runat="server" errormessage="*" controltovalidate="StateText"></asp:requiredfieldvalidator>
<asp:textbox id="StateText" runat="server" columns="2"></asp:textbox>
</td>
</tr>
<tr>
<td>
<asp:Label id="PasswordLabel" runat="server" text="Password:"></asp:Label></td>
<td>
<asp:requiredfieldvalidator id="PasswordRequired" runat="server" errormessage="*" controltovalidate="PasswordText"></asp:requiredfieldvalidator>
<asp:textbox id="PasswordText" runat="server" columns="15" textmode="password"></asp:textbox>
</td>
</tr>
<tr>
<td>
<asp:button id="Submit" onclick="Submit_Click" runat="server"></asp:button>
</td>
<td align="middle">
<asp:Label id="Message" runat="server" forecolor="red" backcolor="yellow" font-size="16 pt" font-italic="true" font-bold="true"></asp:Label></td>
</tr>
</tbody>
</table>
<br />
<center>
<asp:hyperlink id="HomeLink" runat="server" font-size="12 pt" font-bold="true" font-name="Arial" navigateurl="default.aspx">
[ Home ]</asp:hyperlink>
</center>
</form>
</body>
</html>


the error message stated:
"Syntax error in INSERT INTO statement. "

Nabil asked you to post the insert sql statement - - in ALL that code, I can't find an Insert Statement
David, thanks for your help...
I have to reiterate, im a total beginner here !!

This is where Im confused, there isnt any sql insert statements.
This is sample code, that wont run...
To add a row into the dataset the method I think is being used is as follows:-

1) Create a new row object
Row=ClassyDS.Tables("Ads").NewRow

2) fill that object with data for each column
Row.Item("Title") = TitleText.Text
Row.Item("Description") = DescriptionText.Text
Row.Item("Category") = CategoryText.Text
Row.Item("Price") = PriceText.Text
etc,etc,etc

3) Add the row object into the dataset as a new row for the given table
ClassyDS.Tables("Ads").Rows.Add(Row)

This line does, in fact, add the row to the dataset table. But that only happens after the row is created and filled in. This line does not add the row to the database.
To finally do that apparently you use

Adapter.Update(ClassyDS, "Ads")

The update method causes the dataadapter to look through the dataset and find out what it needs to do. In this case, it finds one newly added row, which causes the dataadapter to look for its InsertCommand (filled in by the command builder) and execute it with the newly entered information. This causes the new row to be added to the table in the database.

The error message I get points to this line Adapter.Update(ClassyDS, "Ads")

The code in the previous not is both for enetering new info (which isnt working) and also editing existing data (which works fine)

Hope you understand all this

Thanks Again
To follow on from my previous note...

This is a link to a website where I have added all the sample code from ASP.NET for dummies in a zip file.
I have not modified this code at all, my problem is before I start working on it to learn ASP.NET, the place a new ad option is not working.

Hope someone can help here...

regards Steve

http://www28.brinkster.com/jaxxgolf/

Download the classy.zip file !!
I have put the code in a zip file on this site..

If anybody can get this sample code from ASP.NET for dummies to work when trying to Place a NEw Ad, could they please let me know what the problem is.

Thanks

http://www28.brinkster.com/jaxxgolf/
Ok ... I tried the sample and managed to reproduce the error.

Here's what's happening:

The code uses an OleDbCommandBuilder to automatically generate the SQL statement for you.

If you look at the ACCESS database you will find that one of the columns in the "Ads" table is called "Password". Of course, "Password" is a reserved word in most databases, including ACCESS. So the Insert statement that gets created ends up failing because it is misinterpreting the word "Password". Thankfully Microsoft has already thought of this problem and added two properties to the OleDbCommandBuilder object called "QuotePrefix" and "QuoteSuffix" that can employ special characters to signal to the database that you are not reffering to a reserved word. In the case of ACCESS the characters are "[" and "]". So, if you add the following two lines to ClassyAd.ascx on line 42, you will no longer get the same error.


ClassyCB.QuotePrefix = "["
ClassyCB.QuoteSuffix = "]"

Now you may get aNEW error that states:
"Operation must use an updateable query."

My research indicates that this may either be a permissions problem or a conversion problem. You have to make sure that the ASPNET account has permission to access the directory that contains the file "classydb.mdb". Also, if you converted the ".mdb" file from an earlier version of ACCESS you may need to create a new DB in your version of ACCESS and import the data from the original file. If none of that works go to "http://www.google.com" and search on "Operation must use an updateable query" .

Hope that helps.
Hi Nabil,
That worked a treat !!

Many thanks for your help on this !! Hopefully one day I can return the favour !!

Best Regards
Steve

Tuesday, March 13, 2012

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.
Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do
<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..
Karl
--
http://www.openmymind.net/
"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..
Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...
I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).
so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table>
and you create a style in a css:
table
{
border:1px solid #000;
}
you WILL see the border
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegroups.com...
>
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
>
Object withdrawn :)
Always happy to be proven wrong.

Trouble with Table borders

Hello
I seem to have a re-occuring problem with tables.
Every tiime i create a new table in my code (Table x = new Table();) it
creates in the final code the browser gets the attribute 'border="0"'.(i
prefer putting my styles in a seprate css file)
Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
nothing seems to work.even changing the Table.BorderWidth property creates a
'style="border-width:x"' and stucks me with the 'border="0"'.
It happens even when i create classes derived from Table.

Please help me,it's really annoying.
Thank you.It's hard-coded in the table creation - unfortunetly. But I don't see why
it'd be causing problems with your css decleration? if you do

<table border="0" class="Blah"> and the Blah class defines a border, it
ought to apply it reguarless of what the border says..

Karl
--
http://www.openmymind.net/

"ThePinkPanther" <ThePinkPanther@.discussions.microsoft.com> wrote in message
news:E9E18BBB-B846-40B3-AAD4-A16272C96D68@.microsoft.com...
> Hello
> I seem to have a re-occuring problem with tables.
> Every tiime i create a new table in my code (Table x = new Table();) it
> creates in the final code the browser gets the attribute 'border="0"'.(i
> prefer putting my styles in a seprate css file)
> Doesnt matter what i do, Table.Attributes.Clear(),Table.Style.Clear()
> nothing seems to work.even changing the Table.BorderWidth property creates
> a
> 'style="border-width:x"' and stucks me with the 'border="0"'.
> It happens even when i create classes derived from Table.
> Please help me,it's really annoying.
> Thank you.
> It's hard-coded in the table creation - unfortunetly. But I don't see why
> it'd be causing problems with your css decleration? if you do

> <table border="0" class="Blah"> and the Blah class defines a border, it
> ought to apply it reguarless of what the border says..

Not true, CSS properties are overriden by inline styles. Not very
helpful, I know.
Well, I'm willing to admit that i'm wrong...but...

I agree that external css properties are overriden by inline styles, but
border="0" isn't an inline style, it's an attribute decleration which ARE
overriden by any styles (inline or external).

so if you do:
<table border="0">
<tr><td>asdsa</td></tr>
</table
and you create a style in a css:

table
{
border:1px solid #000;
}

you WILL see the border

Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/

"Flinky Wisty Pomm" <Pathogenix@.gmail.com> wrote in message
news:1139834577.520780.250200@.g47g2000cwa.googlegr oups.com...
>> It's hard-coded in the table creation - unfortunetly. But I don't see why
>> it'd be causing problems with your css decleration? if you do
>> <table border="0" class="Blah"> and the Blah class defines a border, it
>> ought to apply it reguarless of what the border says..
> Not true, CSS properties are overriden by inline styles. Not very
> helpful, I know.
Object withdrawn :)

Always happy to be proven wrong.

Trouble with translating C# into VB.NET code

Hello, I'm trying to implement a function to create zip files in my application. I am using the following articlehttp://msdn.microsoft.com/msdnmag/issues/03/06/ZipCompression/default.aspx
which describes how to perform zipping with C#.
My application is in VB.NET so I am trying to translate a class thatperforms the zipping into VB code. I have managed to translate theclass except for two lines. The original C# code is as follows. Mytranslated VB code with errors in emphasized red color can be found just beneath the C#code.The error message I get for the two lines are:
"c:\inetpub\wwwroot\TestApplication\Zip.vb(81):'TestApplication.VbZip.EnumerationMethod' is a delegate type. Delegateconstruction permits only a single AddressOf expression as an argumentlist. Often an AddressOf expression can be used instead of a delegateconstruction.".
Can anyone help me translating these two lines?

using System;
using System.Collections;
using java.util;
using java.util.zip;
namespace CsZip
{
public delegate Enumeration EnumerationMethod();
/// <summary>
/// Wraps java enumerators
/// </summary>
public class EnumerationAdapter : IEnumerable
{
private class EnumerationWrapper : IEnumerator
{
private EnumerationMethod m_Method;
private Enumeration m_Wrapped;
private object m_Current;
public EnumerationWrapper(EnumerationMethod method)
{
m_Method = method;
}
// IEnumerator
public object Current
{
get { return m_Current; }
}
public void Reset()
{
m_Wrapped = m_Method();
if (m_Wrapped == null)
throw newInvalidOperationException();
}
public bool MoveNext()
{
if (m_Wrapped == null)
Reset();
bool Result = m_Wrapped.hasMoreElements();
if (Result)
m_Current = m_Wrapped.nextElement();
return Result;
}
}
private EnumerationMethod m_Method;
public EnumerationAdapter(EnumerationMethod method)
{
if (method == null)
throw new ArgumentException();
m_Method = method;
}
// IEnumerable
public IEnumerator GetEnumerator()
{
return new EnumerationWrapper(m_Method);
}
}
public delegate bool FilterEntryMethod(ZipEntry e);
/// <summary>
/// Zip stream utils
/// </summary>
public class ZipUtils
{
public static void CopyStream(java.io.InputStream from, java.io.OutputStream to)
{
sbyte[] buffer = new sbyte[8192];
int got;
while ((got = from.read(buffer, 0, buffer.Length)) > 0)
to.write(buffer, 0, got);
}
public static void ExtractZipFile(ZipFile file, string path, FilterEntryMethod filter)
{
foreach(ZipEntry entry in new EnumerationAdapter(newEnumerationMethod(file.entries)))
{
if (!entry.isDirectory())
{
if ((filter == null ||filter(entry)))
{
java.io.InputStream s = file.getInputStream(entry);
try
{
string fname =System.IO.Path.GetFileName(entry.getName());
string newpath = System.IO.Path.Combine(path,System.IO.Path.GetDirectoryName(entry.getName()));
System.IO.Directory.CreateDirectory(newpath);
java.io.FileOutputStream dest = newjava.io.FileOutputStream(System.IO.Path.Combine(newpath, fname));
try
{
CopyStream(s, dest);
}
finally
{
dest.close();
}
}
finally
{
s.close();
}
}
}
}
}
public static ZipFile CreateEmptyZipFile(string fileName)
{
new ZipOutputStream(new java.io.FileOutputStream(fileName)).close();
return new ZipFile(fileName);
}
public static ZipFileUpdateZipFile(ZipFile file, FilterEntryMethod filter, string[] newFiles)
{
string prev = file.getName();
string tmp = System.IO.Path.GetTempFileName();
ZipOutputStream to = new ZipOutputStream(newjava.io.FileOutputStream(tmp));
try
{
CopyEntries(file, to, filter);
// add entries here
if (newFiles != null)
{
foreach(string f in newFiles)
{
ZipEntry z =new ZipEntry(f.Remove(0, System.IO.Path.GetPathRoot(f).Length));
z.setMethod(ZipEntry.DEFLATED);
to.putNextEntry(z);
try
{
java.io.FileInputStream s = newjava.io.FileInputStream(f);
try
{
CopyStream(s, to);
}
finally
{
s.close();
}
}
finally
{
to.closeEntry();
}
}
}
}
finally
{
to.close();
}
file.close();
// now replace the old file with the new one
System.IO.File.Copy(tmp, prev, true);
System.IO.File.Delete(tmp);
return new ZipFile(prev);
}
public static void CopyEntries(ZipFile from, ZipOutputStream to)
{
CopyEntries(from, to, null);
}
public static void CopyEntries(ZipFile from, ZipOutputStream to, FilterEntryMethod filter)
{
foreach(ZipEntry entry in new EnumerationAdapter(newEnumerationMethod(from.entries)))
{
if (filter == null || filter(entry))
{
java.io.InputStream s =from.getInputStream(entry);
try
{
to.putNextEntry(entry);
try
{
CopyStream(s, to);
}
finally
{
to.closeEntry();
}
}
finally
{
s.close();
}
}
}
}
}
}



VB.NET code:
Imports System
Imports System.Collections
Imports java.util
Imports java.util.zip
Namespace VbZip
Public Delegate Function EnumerationMethod() As Enumeration
Public Class EnumerationAdapter : Implements IEnumerable
Private Class EnumerationWrapper : Implements IEnumerator
Private m_Method As EnumerationMethod
Private m_Wrapped As Enumeration
Private m_Current As Object
Public Sub New(ByVal method As EnumerationMethod)
m_Method = method
End Sub
Public ReadOnly Property Current() As Object _
Implements IEnumerator.Current
Get
Return m_Current
End Get
End Property
Public Sub Reset() _
Implements IEnumerator.Reset
m_Wrapped = m_Method
If m_Wrapped Is Nothing Then
Throw New InvalidOperationException
End If
End Sub
Public Function MoveNext() As Boolean _
Implements IEnumerator.MoveNext
If m_Wrapped Is Nothing Then
Reset()
End If
Dim Result As Boolean = m_Wrapped.hasMoreElements()
If Result Then
m_Current = m_Wrapped.nextElement()
End If
Return Result
End Function
End Class
Private m_Method As EnumerationMethod
Public Function EnumerationAdapter(ByVal method As EnumerationMethod)
If method Is Nothing Then
Throw New ArgumentException
End If
m_Method = method
End Function
'IEnumerable
Public Function GetEnumerator() As IEnumerator _
Implements IEnumerable.GetEnumerator
Return New EnumerationWrapper(m_Method)
End Function
End Class
Public Delegate Function FilterEntryMethod(ByVal e As ZipEntry) As Boolean
Public Class ZipUtils
Public Shared Sub CopyStream(ByVal from As java.io.InputStream, _
ByVal tto As java.io.OutputStream)
Dim buffer() As System.SByte = New System.SByte(8192) {}
Dim got As Integer
While (got = from.read(buffer, 0, buffer.Length)) > 0
tto.write(buffer, 0, got)
End While
End Sub
Public Shared SubExtractZipFile(ByVal file As ZipFile, ByVal path As String, ByValfilter As FilterEntryMethod)
ForEach entry As ZipEntry In New EnumerationAdapter(NewEnumerationMethod(file.entries))
If Not entry.isDirectory() Then
If (filter = Nothing Or filter(entry)) Then
Dim s As java.io.InputStream = file.getInputStream(entry)
Try
Dim fname As String = System.IO.Path.GetFileName(entry.getName())
Dim Newpath As String = System.IO.Path.Combine(path,System.IO.Path.GetDirectoryName(entry.getName()))
System.IO.Directory.CreateDirectory(Newpath)
Dim dest As java.io.FileOutputStream = Newjava.io.FileOutputStream(System.IO.Path.Combine(Newpath, fname))
Try
CopyStream(s, dest)
Finally
dest.close()
End Try
Finally
s.close()
End Try
End If
End If
Next
End Sub
Public Shared Function CreateEmptyZipFile(ByVal fileName As String) As ZipFile
Dimzos As New ZipOutputStream(New java.io.FileOutputStream(fileName))
zos.close()
Return New ZipFile(fileName)
End Function
Public Shared FunctionUpdateZipFile(ByVal file As ZipFile, ByVal filter As FilterEntryMethod,_
ByVal newFiles As String())
Dim prev As String = file.getName
Dim tmp As String = System.IO.Path.GetTempFileName
Dimtto As ZipOutputStream = New ZipOutputStream(Newjava.io.FileOutputStream(tmp))
Try
CopyEntries(file, tto, filter)
If Not newFiles Is Nothing Then
For Each f As String In newFiles
Dim z As ZipEntry = New ZipEntry(f.Remove(0,System.IO.Path.GetPathRoot(f).Length))
z.setMethod(ZipEntry.DEFLATED)
tto.putNextEntry(z)
Try
Dim s As New java.io.FileInputStream(f)
Try
CopyStream(s, tto)
Finally
s.close()
End Try
Finally
tto.closeEntry()
End Try
Next
End If
Finally
tto.close()
End Try
file.close()
'now replace the old file with the new one
System.IO.File.Copy(tmp, prev, True)
System.IO.File.Delete(tmp)
Return New ZipFile(prev)
End Function
Public Shared Sub CopyEntries(ByVal from As ZipFile, ByVal tto As ZipOutputStream, _
ByVal filter As FilterEntryMethod)
ForEach entry As ZipEntry In New EnumerationAdapter(NewEnumerationMethod(from.entries))
If filter Is Nothing Or filter(entry) Then
Dim s As java.io.InputStream = from.getInputStream(entry)
Try
tto.putNextEntry(entry)
Try
CopyStream(s, tto)
Finally
tto.closeEntry()
End Try
Finally
s.close()
End Try
End If
Next
End Sub
End Class
End Namespace
try the convertor it is for both languages

http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
I have tried a different translator before, and have just tried yoursuggestion. However, the results are the same and the conversion doesnot seem to be perfect. It still requires some manual tuning which Ihave done except for the two lines emphasized in red. Anyone here canhelp me out?Smile [:)]

i know it is not perfect but what i do is deal with errors manually other wise you will not be albe to solve the problem... we can help you if you can not solve the error so you deal in that case with few lines of code rather than 100's lines

Well, the error I'm getting is for the two lines emphasizes in red:
c:\inetpub\wwwroot\TestApplication\Zip.vb(81): 'TestApplication.VbZip.EnumerationMethod' is a delegate type. Delegate construction permits only a single AddressOf expression as an argument list. Often an AddressOf expression can be used instead of a delegate construction.".
I don't know too well how to solve this, so any insight is appreciated.

if you specify the code that making the problem we might help you at the mean time look at this if that will help!!
http://abstractvb.com/code.asp?A=1084
http://www.startvbdotnet.com/language/enumeration.aspx