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. db not able to catch the data

db not able to catch the data

Scheduled Pinned Locked Moved ASP.NET
database
14 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.
  • L lhahehal

    hi there , i am having problems getting my data to the db .. there are no errors displaying .. its just that data wont go in ... Dim a As String Dim b As String a = TextBox1.Text Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\temp\db1.mdb") Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'" 'Dim strSQL As String = "INSERT INTO Settins (PhotoUpload) VALUES (@img) WHERE UserID = '" + rId + "'" Dim cmd As New OleDbCommand(strSQL, cnn) Try cnn.Open() cmd.ExecuteNonQuery() Catch ex As Exception 'lb_Msg.Text = ex.Message Finally If Not cmd Is Nothing Then cmd.Dispose() End If If Not cnn Is Nothing Then cnn.Close() cnn.Dispose() End If End Try End Sub

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

    lhahehal wrote:

    Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'"

    This is telling the database to insert in to the columns called yo and yoyo the value in the column called a. Is that what you want? I suspect not because earlier in the code you have:

    lhahehal wrote:

    Dim a As String a = TextBox1.Text

    I am guessing that what you actually want is the value of the variable a in your VB.NET code. However, the database cannot see that value unless you tell it about it. So you have to construct your query so it does tell it about the value. Next, there is a major security hole in your application that you need to clear up because it is open to a SQL Injection Attack which can compromise your database. You need to read SQL Injection Attacks and Tips on How to Prevent Them[^] ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell

    1 Reply Last reply
    0
    • L lhahehal

      hi there , i am having problems getting my data to the db .. there are no errors displaying .. its just that data wont go in ... Dim a As String Dim b As String a = TextBox1.Text Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\temp\db1.mdb") Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'" 'Dim strSQL As String = "INSERT INTO Settins (PhotoUpload) VALUES (@img) WHERE UserID = '" + rId + "'" Dim cmd As New OleDbCommand(strSQL, cnn) Try cnn.Open() cmd.ExecuteNonQuery() Catch ex As Exception 'lb_Msg.Text = ex.Message Finally If Not cmd Is Nothing Then cmd.Dispose() End If If Not cnn Is Nothing Then cnn.Close() cnn.Dispose() End If End Try End Sub

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

      Of course there is no errors displaying. You catch the errors and ignore them. You have commented out the only code that would do anything in case of an error. --- b { font-weight: normal; }

      L 1 Reply Last reply
      0
      • G Guffa

        Of course there is no errors displaying. You catch the errors and ignore them. You have commented out the only code that would do anything in case of an error. --- b { font-weight: normal; }

        L Offline
        L Offline
        lhahehal
        wrote on last edited by
        #4

        i have uncomment the exception and it prompts Missing semicolon (;) at end of SQL statement. but i could not see anywhere to insert it as its not java ...

        R 1 Reply Last reply
        0
        • L lhahehal

          i have uncomment the exception and it prompts Missing semicolon (;) at end of SQL statement. but i could not see anywhere to insert it as its not java ...

          R Offline
          R Offline
          RSArockiam
          wrote on last edited by
          #5

          Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'" Here values(a,a) is completely wrong one. You have to replace this into Values('" & a & "','" & a & "')" if the fields are string this code , if this fields are numeric it should be Values(" & a & "," & a & ")" Regards R.Arockiapathinathan

          L 1 Reply Last reply
          0
          • R RSArockiam

            Dim strSQL As String = "INSERT INTO Table1 (yo,yoyo) VALUES (a,a) where user = '" + TextBox2.Text + "'" Here values(a,a) is completely wrong one. You have to replace this into Values('" & a & "','" & a & "')" if the fields are string this code , if this fields are numeric it should be Values(" & a & "," & a & ")" Regards R.Arockiapathinathan

            L Offline
            L Offline
            lhahehal
            wrote on last edited by
            #6

            hi thx .. it solve the problem ... now i am trying update but seems to hit a different kind of problem .. Server was unable to process request. --> No value given for one or more required parameters. Dim a As String Dim b As String Dim strSNameFont As String Dim strSNameSize As String Dim strSNameColor As String Dim strNameBold As String Dim strNameItalic As String Dim strnameunderline As String strSNameFont = ddlSNameFont.SelectedValue strSNameSize = ddlSNameSize.SelectedValue strSNameColor = ddlSNameColor.SelectedValue strNameBold = cbNameBold.Checked strNameItalic = cbNameItalic.Checked Dim i As Integer = 1 strnameunderline = "nil" a = TextBox1.Text Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\TDB.mdb") Dim strSQL As String = "UPDATE Settings SET NameFont = '" + strSNameFont + "', FontSize = '" + strSNameSize + _ "', FontColor = '" + strSNameColor + _ "', FBold = '" + strNameBold + _ "', FItalic = '" + strNameItalic + _ "' WHERE UserID='" + TextBox2.Text + "'" Dim cmd As New OleDbCommand(strSQL, cnn) cnn.Open() _**cmd.ExecuteNonQuery()**_ <----- in red cnn.Close() End Sub

            G 1 Reply Last reply
            0
            • L lhahehal

              hi thx .. it solve the problem ... now i am trying update but seems to hit a different kind of problem .. Server was unable to process request. --> No value given for one or more required parameters. Dim a As String Dim b As String Dim strSNameFont As String Dim strSNameSize As String Dim strSNameColor As String Dim strNameBold As String Dim strNameItalic As String Dim strnameunderline As String strSNameFont = ddlSNameFont.SelectedValue strSNameSize = ddlSNameSize.SelectedValue strSNameColor = ddlSNameColor.SelectedValue strNameBold = cbNameBold.Checked strNameItalic = cbNameItalic.Checked Dim i As Integer = 1 strnameunderline = "nil" a = TextBox1.Text Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\TDB.mdb") Dim strSQL As String = "UPDATE Settings SET NameFont = '" + strSNameFont + "', FontSize = '" + strSNameSize + _ "', FontColor = '" + strSNameColor + _ "', FBold = '" + strNameBold + _ "', FItalic = '" + strNameItalic + _ "' WHERE UserID='" + TextBox2.Text + "'" Dim cmd As New OleDbCommand(strSQL, cnn) cnn.Open() _**cmd.ExecuteNonQuery()**_ <----- in red cnn.Close() End Sub

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

              That means that one or more of the names in the query does not exist in the database. --- b { font-weight: normal; }

              R 1 Reply Last reply
              0
              • G Guffa

                That means that one or more of the names in the query does not exist in the database. --- b { font-weight: normal; }

                R Offline
                R Offline
                RSArockiam
                wrote on last edited by
                #8

                may be the tablename Settings make some problem. try like this update [settings] .... And also from ur code, all fields are string. Is it correct? if any of the fields are non string then remove single codes both sides. Regards R.Arockiapathinathan

                L 1 Reply Last reply
                0
                • R RSArockiam

                  may be the tablename Settings make some problem. try like this update [settings] .... And also from ur code, all fields are string. Is it correct? if any of the fields are non string then remove single codes both sides. Regards R.Arockiapathinathan

                  L Offline
                  L Offline
                  lhahehal
                  wrote on last edited by
                  #9

                  yup i checked through the database , all are string , i did not want to update the ole object so i left it out ... i tried [setting] but it prompts the same error ...

                  R 1 Reply Last reply
                  0
                  • L lhahehal

                    yup i checked through the database , all are string , i did not want to update the ole object so i left it out ... i tried [setting] but it prompts the same error ...

                    R Offline
                    R Offline
                    RSArockiam
                    wrote on last edited by
                    #10

                    double check the field names carefully No value given for one or more required parameters Normally this error will comes when field names are wrong Regards R.Arockiapathinathan

                    L 1 Reply Last reply
                    0
                    • R RSArockiam

                      double check the field names carefully No value given for one or more required parameters Normally this error will comes when field names are wrong Regards R.Arockiapathinathan

                      L Offline
                      L Offline
                      lhahehal
                      wrote on last edited by
                      #11

                      hmm the strange thing is when i query from access its fine .. then i tried retyping it .. and suddenly it works ... strange strange now i face another problem ... Input string was not in a correct format. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 151: Line 152: 'set setting checkbox Line 153: cbNameBold.Checked = StoreSetting.NameBold <-- red namebold is a get/set method ...

                      R 1 Reply Last reply
                      0
                      • L lhahehal

                        hmm the strange thing is when i query from access its fine .. then i tried retyping it .. and suddenly it works ... strange strange now i face another problem ... Input string was not in a correct format. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: Line 151: Line 152: 'set setting checkbox Line 153: cbNameBold.Checked = StoreSetting.NameBold <-- red namebold is a get/set method ...

                        R Offline
                        R Offline
                        RSArockiam
                        wrote on last edited by
                        #12

                        Checked property will accept only boolean value true or false. so your property should be return true or false instead of string. Regards R.Arockiapathinathan

                        L 1 Reply Last reply
                        0
                        • R RSArockiam

                          Checked property will accept only boolean value true or false. so your property should be return true or false instead of string. Regards R.Arockiapathinathan

                          L Offline
                          L Offline
                          lhahehal
                          wrote on last edited by
                          #13

                          kk thx .. got it to work ..

                          I 1 Reply Last reply
                          0
                          • L lhahehal

                            kk thx .. got it to work ..

                            I Offline
                            I Offline
                            Ista
                            wrote on last edited by
                            #14

                            Im coming on the end of this but string myString = "true"; Checked = Convert.ToBoolean( myString ); will work also 1 line of code equals many bugs. So don't write any!!

                            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