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. General Programming
  3. C#
  4. a query. [modified]

a query. [modified]

Scheduled Pinned Locked Moved C#
databasequestionhelptutorial
10 Posts 5 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.
  • N Offline
    N Offline
    Nekshan
    wrote on last edited by
    #1

    When i logout, i want that 'logoutdatetime' in database,its format is datetime in database. So i have written query, but it is giving error. strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong? If u can plz guide. And.. lasttime nu : str = str1 + "#" + str2 + "#" + str3 ...barobar implement nai thayu haji,i'll try it 2mrw now. thanx nekshan -- modified at 5:20 Monday 19th February, 2007

    P V G C 4 Replies Last reply
    0
    • N Nekshan

      When i logout, i want that 'logoutdatetime' in database,its format is datetime in database. So i have written query, but it is giving error. strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong? If u can plz guide. And.. lasttime nu : str = str1 + "#" + str2 + "#" + str3 ...barobar implement nai thayu haji,i'll try it 2mrw now. thanx nekshan -- modified at 5:20 Monday 19th February, 2007

      P Offline
      P Offline
      Pratik Vasant Shah
      wrote on last edited by
      #2

      What is the format of the date you wish to store in the database??

      Thanking you in Advance Regards Pratik Shah

      1 Reply Last reply
      0
      • N Nekshan

        When i logout, i want that 'logoutdatetime' in database,its format is datetime in database. So i have written query, but it is giving error. strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong? If u can plz guide. And.. lasttime nu : str = str1 + "#" + str2 + "#" + str3 ...barobar implement nai thayu haji,i'll try it 2mrw now. thanx nekshan -- modified at 5:20 Monday 19th February, 2007

        V Offline
        V Offline
        virendra patel
        wrote on last edited by
        #3

        strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")';"

        N 1 Reply Last reply
        0
        • V virendra patel

          strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")';"

          N Offline
          N Offline
          Nekshan
          wrote on last edited by
          #4

          Incorrect syntax near : '(" + DateTime.Now + ")' I m checking it in query analyser. nekshan.

          V 2 Replies Last reply
          0
          • N Nekshan

            Incorrect syntax near : '(" + DateTime.Now + ")' I m checking it in query analyser. nekshan.

            V Offline
            V Offline
            virendra patel
            wrote on last edited by
            #5

            insert into dashboarddealerlogin (logoutdatetime) values (GETDATE()) write this in query bilder.

            N 1 Reply Last reply
            0
            • N Nekshan

              When i logout, i want that 'logoutdatetime' in database,its format is datetime in database. So i have written query, but it is giving error. strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong? If u can plz guide. And.. lasttime nu : str = str1 + "#" + str2 + "#" + str3 ...barobar implement nai thayu haji,i'll try it 2mrw now. thanx nekshan -- modified at 5:20 Monday 19th February, 2007

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              Nekshan wrote:

              strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong?

              You have forgotten the parenthesis around the values, and you have forgotten to convert the DateTime value into a string: strQury = "insert into dashboarddealerlogin (logoutdatetime) values ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'); You should make sure that the date format that you use is understood correctly by the database. I prefer the ISO 8601 date format as it's unambigous.

              --- single minded; short sighted; long gone;

              1 Reply Last reply
              0
              • N Nekshan

                Incorrect syntax near : '(" + DateTime.Now + ")' I m checking it in query analyser. nekshan.

                V Offline
                V Offline
                virendra patel
                wrote on last edited by
                #7

                u test query in sql query bilder but system.datatime.now() is a function of vb.net so its not run in builder but code i sent u is correct '(" + DateTime.Now + ")'

                1 Reply Last reply
                0
                • N Nekshan

                  When i logout, i want that 'logoutdatetime' in database,its format is datetime in database. So i have written query, but it is giving error. strQury = "insert into dashboarddealerlogin (logoutdatetime) values '" + DateTime.Now + "'; what is wrong? If u can plz guide. And.. lasttime nu : str = str1 + "#" + str2 + "#" + str3 ...barobar implement nai thayu haji,i'll try it 2mrw now. thanx nekshan -- modified at 5:20 Monday 19th February, 2007

                  C Offline
                  C Offline
                  Colin Angus Mackay
                  wrote on last edited by
                  #8

                  Nekshan wrote:

                  ...barobar implement nai thayu haji,i'll try it 2mrw now.

                  :confused:


                  Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

                  1 Reply Last reply
                  0
                  • V virendra patel

                    insert into dashboarddealerlogin (logoutdatetime) values (GETDATE()) write this in query bilder.

                    N Offline
                    N Offline
                    Nekshan
                    wrote on last edited by
                    #9

                    insert into dashboarddealerlogin (logoutdatetime) values (GETDATE()) It is giving error : Cannot insert value null in logoutdatetime. Anywaz, let it b. Just c this : private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs n i have to write it here only. Now i want to use this 'int n' in a function in form2.cs funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n'. how can i do this? thanx. nekshan.

                    V 1 Reply Last reply
                    0
                    • N Nekshan

                      insert into dashboarddealerlogin (logoutdatetime) values (GETDATE()) It is giving error : Cannot insert value null in logoutdatetime. Anywaz, let it b. Just c this : private void logout_Click(object sender, EventArgs e) { conn.Open(); string strQury = ""; strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; SqlCommand cm = new SqlCommand(strQury, conn); int n = Convert.ToInt32(cm.ExecuteScalar()); } I have written this code in form1.cs n i have to write it here only. Now i want to use this 'int n' in a function in form2.cs funEntrylogin(m, i, tb_id.Text, tb_pswd.Text, DateTime.Now,n); but here it is giving error on 'n'. how can i do this? thanx. nekshan.

                      V Offline
                      V Offline
                      virendra patel
                      wrote on last edited by
                      #10

                      'private void logout_Click(object sender, EventArgs e) '{ 'conn.Open(); 'string strQury = ""; 'strQury = "insert into dashboarddealerlogin (logoutdatetime) values '(" + DateTime.Now + ")'"; 'SqlCommand cm = new SqlCommand(strQury, conn); 'int n = Convert.ToInt32(cm.ExecuteScalar()); '} 'above query is correct.return value for n is (0 or 1) if n=0 then not row update and n=1 then row updated. error is on something else.

                      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