Gotta hand in my ASP.NET project in 12 hours, last minute questions!!!
-
As said on the title, time is running out fast and I'm trying to squish as much bugs as possible, I have some urgent last minute questions: I have the following code: OleDbConnection objConnection; OleDbCommand objCommand; string strSQL; string strConnect; strSQL="select screenname, pw from Member where (email='"+txtEmail.Text+"')"; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Member.mdb ;"; objConnection = new OleDbConnection(strConnect); objConnection.Open(); objCommand = new OleDbCommand(strSQL, objConnection); object result = objCommand.ExecuteScalar(); if (result == null) { Response.Redirect("forgetpasswordfailed.aspx"); objConnection.Close(); } else { Session["email"] = txtEmail.Text; objConnection.Close(); Response.Redirect("forgetpasswordsent.aspx"); } I also need to find out the value of screenname and pw, how do I extract their value from the result? Second question, I have data in the date format in Access 2003, everytime I extract the date data into a textbox to be displayed it goes something like this: 1/3/2006 00:00:00, how do I remove the 00:00:00? I would really appreciate the help, THANKS!!! -- modified at 14:52 Tuesday 3rd January, 2006
-
As said on the title, time is running out fast and I'm trying to squish as much bugs as possible, I have some urgent last minute questions: I have the following code: OleDbConnection objConnection; OleDbCommand objCommand; string strSQL; string strConnect; strSQL="select screenname, pw from Member where (email='"+txtEmail.Text+"')"; strConnect = @"Provider=Microsoft.Jet.OLEDB.4.0;"; strConnect += @"Data Source = D:\Database\"; strConnect += @"Member.mdb ;"; objConnection = new OleDbConnection(strConnect); objConnection.Open(); objCommand = new OleDbCommand(strSQL, objConnection); object result = objCommand.ExecuteScalar(); if (result == null) { Response.Redirect("forgetpasswordfailed.aspx"); objConnection.Close(); } else { Session["email"] = txtEmail.Text; objConnection.Close(); Response.Redirect("forgetpasswordsent.aspx"); } I also need to find out the value of screenname and pw, how do I extract their value from the result? Second question, I have data in the date format in Access 2003, everytime I extract the date data into a textbox to be displayed it goes something like this: 1/3/2006 00:00:00, how do I remove the 00:00:00? I would really appreciate the help, THANKS!!! -- modified at 14:52 Tuesday 3rd January, 2006
Instead of declaring result as object, declare it as a OleDbDataReader, and then execute: OledbDataReader result = objCommand.ExecuteReader(); in your else clause, you can retrieve you screenname and pw, with: if(result.Read()){ result.getString[0]; // Screenname result.getString[1]; // pw } Do make sure to close the reader when you are done. Second question: to display only the date part, pass the value to a DateTime type variable, and then show it as: DateTime DateToShow = DateTime.Now; // This is a sample, assign here your date DateToShow.ToString("MM/dd/yyyy"); //and this way it'll only show the date part. Let's see if this works. :suss: daniero
-
Instead of declaring result as object, declare it as a OleDbDataReader, and then execute: OledbDataReader result = objCommand.ExecuteReader(); in your else clause, you can retrieve you screenname and pw, with: if(result.Read()){ result.getString[0]; // Screenname result.getString[1]; // pw } Do make sure to close the reader when you are done. Second question: to display only the date part, pass the value to a DateTime type variable, and then show it as: DateTime DateToShow = DateTime.Now; // This is a sample, assign here your date DateToShow.ToString("MM/dd/yyyy"); //and this way it'll only show the date part. Let's see if this works. :suss: daniero
Thanks for the reply, I just tinkered with the code and it worked By the way, how do you to show just the time? Since I have another variable that only stores the time, not the date. And I am still stuck in passing session variables via the URL with a adrotator, how do you guys get it done? I have to pass the product ID of a banner in a adrotator to the products details page to display item details. So I guess I can only go with the URL and not the codes itself.
-
Thanks for the reply, I just tinkered with the code and it worked By the way, how do you to show just the time? Since I have another variable that only stores the time, not the date. And I am still stuck in passing session variables via the URL with a adrotator, how do you guys get it done? I have to pass the product ID of a banner in a adrotator to the products details page to display item details. So I guess I can only go with the URL and not the codes itself.
DateTime TimeToShow = DateTime.Now; TimeToShow.ToString("hh:mm:ss tt"); When you have this code written, you can press F1 on the ToString and you'll see full information about its overload for the datetime struct. I... don't really understand what you mean... passing session variables via the URL with a adrotator?? :confused: daniero
-
DateTime TimeToShow = DateTime.Now; TimeToShow.ToString("hh:mm:ss tt"); When you have this code written, you can press F1 on the ToString and you'll see full information about its overload for the datetime struct. I... don't really understand what you mean... passing session variables via the URL with a adrotator?? :confused: daniero
Well, we can forget about the adrotator for now. Let's say I have an image of an product, and I want the user to able to click on it and be redirected to its product details. In order to do that I need to pass the product ID value to the products details page. Since I am using a regular HTML image there's no codes to play with, just the URL, so what can I do? (I know I can use ImageURL control, but I need to know if it can be done with the URL only? I tried xxx.aspx?myvarname=xxxx but it didn't work) By the way, on the date/time issue before, how do you format it in a Datagrid control? I tried using "MM/dd/yyyy", ("MM/dd/yyyy") in the formatting expression but it didn't work, it displays the entire "MM/dd/yyyy" instead.
-
Well, we can forget about the adrotator for now. Let's say I have an image of an product, and I want the user to able to click on it and be redirected to its product details. In order to do that I need to pass the product ID value to the products details page. Since I am using a regular HTML image there's no codes to play with, just the URL, so what can I do? (I know I can use ImageURL control, but I need to know if it can be done with the URL only? I tried xxx.aspx?myvarname=xxxx but it didn't work) By the way, on the date/time issue before, how do you format it in a Datagrid control? I tried using "MM/dd/yyyy", ("MM/dd/yyyy") in the formatting expression but it didn't work, it displays the entire "MM/dd/yyyy" instead.
I don't think I should bail you out but anyway. To use the image, use an ImageButton Control. You can set the parameter in the command argument. Then you can pass that parameter via query string or session object to the next page. Date Format options are {0:D} date/datetime Long date format ("Thursday, August 06, 1996"). Date format depends on the culture settting of the page or the Web.config file. {0:d} date/datetime Short date format ("12/31/99"). {0:yy-MM-dd} date/datetime "People who never make mistakes, never do anything." My Blog
-
Well, we can forget about the adrotator for now. Let's say I have an image of an product, and I want the user to able to click on it and be redirected to its product details. In order to do that I need to pass the product ID value to the products details page. Since I am using a regular HTML image there's no codes to play with, just the URL, so what can I do? (I know I can use ImageURL control, but I need to know if it can be done with the URL only? I tried xxx.aspx?myvarname=xxxx but it didn't work) By the way, on the date/time issue before, how do you format it in a Datagrid control? I tried using "MM/dd/yyyy", ("MM/dd/yyyy") in the formatting expression but it didn't work, it displays the entire "MM/dd/yyyy" instead.
Done by URL is just like Todd says, querystring, so to retrieve the value on the other page just call for: string stringvar = Request.Querystring["myvaluename"]; daniero
-
Done by URL is just like Todd says, querystring, so to retrieve the value on the other page just call for: string stringvar = Request.Querystring["myvaluename"]; daniero
Thanks for the help. I am aware of that, I need to pass it via URL because I am planning to use an adrotator to show a couple of ads. So when user clicks on the ad it will show the respective product item details. Since adrotator does not offer any codebehinds for declaring a session, I believe I can only do it via the URL. Is that correct, or am I wrong? 7 hours to go.....damn THANKS!!!
-
Thanks for the help. I am aware of that, I need to pass it via URL because I am planning to use an adrotator to show a couple of ads. So when user clicks on the ad it will show the respective product item details. Since adrotator does not offer any codebehinds for declaring a session, I believe I can only do it via the URL. Is that correct, or am I wrong? 7 hours to go.....damn THANKS!!!
yes you can use an adrotator in codebehind, you just need to add in the tag the attribute runat="server" and an id="adrotatorid" and then the control should show up as a htmlgenericcontrol or something like that. Then you can set the text in codebehind to the adrotator like that. If it doesn't show up in codebehind you can manually add it as protected htmlgenericcontrol adrotatorid; and then you can use it. Can you use the adrotator web form control?? this way you don't have to test and see if it works if the this adrotator control already works for you. I think I'm a bit confused about what you need to do.