Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Gotta hand in my ASP.NET project in 12 hours, last minute questions!!!

Gotta hand in my ASP.NET project in 12 hours, last minute questions!!!

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netdatabasehelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Infernojericho
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • I Infernojericho

      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

      D Offline
      D Offline
      Daniel Santillanes
      wrote on last edited by
      #2

      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

      I 1 Reply Last reply
      0
      • D Daniel Santillanes

        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

        I Offline
        I Offline
        Infernojericho
        wrote on last edited by
        #3

        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.

        D 1 Reply Last reply
        0
        • I Infernojericho

          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.

          D Offline
          D Offline
          Daniel Santillanes
          wrote on last edited by
          #4

          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

          I 1 Reply Last reply
          0
          • D Daniel Santillanes

            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

            I Offline
            I Offline
            Infernojericho
            wrote on last edited by
            #5

            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.

            T D 2 Replies Last reply
            0
            • I Infernojericho

              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.

              T Offline
              T Offline
              ToddHileHoffer
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • I Infernojericho

                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.

                D Offline
                D Offline
                Daniel Santillanes
                wrote on last edited by
                #7

                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

                I 1 Reply Last reply
                0
                • D Daniel Santillanes

                  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

                  I Offline
                  I Offline
                  Infernojericho
                  wrote on last edited by
                  #8

                  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!!!

                  D 1 Reply Last reply
                  0
                  • I Infernojericho

                    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!!!

                    D Offline
                    D Offline
                    Daniel Santillanes
                    wrote on last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups