I can't add infromation to my Projet.mdb ! please help me ! this is my code

Try


            Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =  C:\projet.mdb"

            Dim Save As New OleDbCommand
            Dim Conn As New OleDbConnection(ConStr)

            Save.CommandText = "INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)"
            Save.Parameters.AddWithValue("@p1", TextBox1.Text)
            Save.Parameters.AddWithValue("@p2", TextBox2.Text)
            Save.Parameters.AddWithValue("@p3", TextBox3.Text)
            Save.Parameters.AddWithValue("@p4", TextBox4.Text)
            Save.Parameters.AddWithValue("@p5", DateTimePicker1.Text)
            Save.Connection = Conn
            Conn.Open()
            Save.ExecuteNonQuery()
            MsgBox("Ajout réussi ")
            frm1.Show()
        Catch ex As Exception
            Exit Sub
        End Try

Have you tried putting all of your connection items and actions before you do the parameters?

How ??

Example:

Dim Conn as New OledbConnection(ConStr)
con.Open()
Dim Save as New OledbCommand("INSERT INTO Client(Nom,Prenom,Adresse,Téléphone,date) VALUES(@p1,@p2,@p3,@p4,@p5)",Conn)

'Add parameters'

Save.ExecuteNonQuery()

This might be silly, but try changing date to [date] , as it might be reserved word.

Everything's alright except that u failed to use the dataadapter class found in the OleDb Class library, also, for ur database query functions to work, you have to initialize a command builder class which is also found in the class library mentioned above, initialize it with this statement - private cmbuilder as new OleDb.OleDbCommandBuilder(dataadapter[which must have been initialized]). This is how u initialize the dataadapter- private dataadapter as new OldDb.OlddbDataAdapter(query string)., use the dataadapter as a link to d database. Initialize a datatable object, then call the fill method of the dataadapter (the intellisense list will give u a hint on what to do at each point in time). Remember, the dataadapter can also update the database with new data by just a method call with the right parameters, delete data, e.t.c., forgive my typing if its inconvenient for u. (i'm using a mobile phone).

if these are the only fields in ur table client then y use the field name just use the parameters
one mistake is u shud use datetimepicker1.value and not text

Give a try

Try
   Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = C:\projet.mdb"
   Dim Save As OleDbCommand
   Save = New OleDbCommand("INSERT INTO Client("'+TextBox1.Text+'","'+ TextBox2.Text+'", "'+ TextBox3.Text+'", "'+TextBox4.Text+'",'"DateTimePicker1.Value+'")", ConStr)
   Dim DBReader As OleDbDataReader = Save.ExecuteReader
   DBReader.Close()
Catch ex As Exception
   Exit Sub
End Try

hye! since i'm a new members, can anyone help me.

what query should i used to join the table example LOGIN table with REGISTRATION table. then where should i store the query? im using vb 2010 + microsoft access 2003

here's the details about my data table.

** LOGIN : staff_id (PK), Username
REGISTER : staff_Id (PK), staff_name, Username**

Something like this:

Dim sqls as String = "SELECT lastname, firstname, tag" & _
     "FROM drivers, vehicles " & _
     "WHERE drivers.location = vehicles.location"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.