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. Database & SysAdmin
  3. Database
  4. database

database

Scheduled Pinned Locked Moved Database
databasehelpquestion
3 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.
  • S Offline
    S Offline
    surender singh
    wrote on last edited by
    #1

    Dim cn As String
    con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\surendera\Documents\student.accdb"

       cn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\surendera\\Documents\\student.accdb"
       con = New OleDbConnection(cn)
       cmd.Connection = con
       con.Open()
       cmd.CommandText = "INSERT into user\_acnt(user\_name,pas\_word) values('" + login.TextBox1.Text + "' ," + login.TextBox2.Text.ToString + ")"
       cmd.ExecuteNonQuery()
       MsgBox("record successfully saved", vbInformation)
       con.Close()
    

    what is the problem in this code...when i run this code it says no value given for some parameter. this code is written within a vb clas named class1 and table name is useracnt plz suggest me the solution

    surendera singh

    L Richard DeemingR 2 Replies Last reply
    0
    • S surender singh

      Dim cn As String
      con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\surendera\Documents\student.accdb"

         cn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\surendera\\Documents\\student.accdb"
         con = New OleDbConnection(cn)
         cmd.Connection = con
         con.Open()
         cmd.CommandText = "INSERT into user\_acnt(user\_name,pas\_word) values('" + login.TextBox1.Text + "' ," + login.TextBox2.Text.ToString + ")"
         cmd.ExecuteNonQuery()
         MsgBox("record successfully saved", vbInformation)
         con.Close()
      

      what is the problem in this code...when i run this code it says no value given for some parameter. this code is written within a vb clas named class1 and table name is useracnt plz suggest me the solution

      surendera singh

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      There seems to be some confusing code there; you have the connection string twice. You are also using string concatenation in your INSERT statement which leaves you open to SQL injection attacks, and the loss or destruction of your database. You are also displaying the message "record successfully saved" without checking that it actuallky has been, so leading to other errors that you will not know about. I suggest getting hold of some learning materials before going any further.

      1 Reply Last reply
      0
      • S surender singh

        Dim cn As String
        con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\surendera\Documents\student.accdb"

           cn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\surendera\\Documents\\student.accdb"
           con = New OleDbConnection(cn)
           cmd.Connection = con
           con.Open()
           cmd.CommandText = "INSERT into user\_acnt(user\_name,pas\_word) values('" + login.TextBox1.Text + "' ," + login.TextBox2.Text.ToString + ")"
           cmd.ExecuteNonQuery()
           MsgBox("record successfully saved", vbInformation)
           con.Close()
        

        what is the problem in this code...when i run this code it says no value given for some parameter. this code is written within a vb clas named class1 and table name is useracnt plz suggest me the solution

        surendera singh

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #3

        In addition to the SQL Injection[^] vulnerability, you're also storing passwords in plain text. You should only ever store a salted hash of the user's password. You should also wrap the connection and command objects in Using blocks, to ensure that their resources are properly cleaned up. You should also give your controls proper names, so that their meaning is obvious. Using the default names (TextBox1, TextBox2, etc.) will only confuse you when you come back to this code later. To fix the immediate problem, use a parameterized query:

        Using con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\surendera\Documents\student.accdb")
        Using cmd As New OleDbCommand("INSERT into user_acnt (user_name, pas_word) values (?, ?)", con)

            ' OleDb doesn't use named parameters, so the names don't matter here:
            cmd.Parameters.AddWithValue("p0", login.UserNameTextBox.Text)
            cmd.Parameters.AddWithValue("p1", login.PasswordTextBox.Text)
            
            con.Open()
            cmd.ExecuteNonQuery()
        End Using
        

        End Using

        Then, go and read the following articles, and change your database design to store the passwords securely: Secure Password Authentication Explained Simply[^] Salted Password Hashing - Doing it Right[^]


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        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