Aide

Résolu
theking32 Messages postés 2 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 23 octobre 2008 - 23 oct. 2008 à 16:44
theking32 Messages postés 2 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 23 octobre 2008 - 23 oct. 2008 à 16:45
slt tlm, j'ai un prob ds mon projet, je lie un datagridview sans aucun souci à une base de données qui le lit, je met des bottons de supprission, nouveau,  modifier et enregistrer. et j'ecrit un code ds botton modifier pour modifier une ligne ds datagridview, mais lorsk je click sur le botton enregistrer rien fait. voila le code de botton enregistrer, si quelqu'un a une idéé.
merci,

1 réponse

theking32 Messages postés 2 Date d'inscription lundi 6 octobre 2008 Statut Membre Dernière intervention 23 octobre 2008
23 oct. 2008 à 16:45
le code est :


Private
Sub Button4_Click(
ByVal sender
As System.Object,
ByVal e
As System.EventArgs)
Handles Button4.Click



If
TextBox2.Enabled =

False



And
TextBox2.Text <>

""



Then








Dim
cmd1

As



New
OleDbCommandcmd1.CommandType = CommandType.Text

cmd1.Connection = Form1.cnx

cmd1.CommandText =


"update table1 set passe= TextBox1.Text where user= '"
& TextBox2.Text &

"' "

cmd1.ExecuteNonQuery()


datafill()










Else






If
TextBox2.Text <>

""



And
TextBox1.Text <>

""



Then






Dim
cmd

As



New
OleDbCommand


Dim
da

As



New
OleDbDataAdaptercmd.CommandType = CommandType.Text

cmd.CommandText =


"insert into table1 values ('"
& TextBox2.Text &

"','"
& TextBox1.Text &

"')"

cmd.Connection = Form1.cnx


da.InsertCommand = cmd


da.InsertCommand.ExecuteNonQuery()


datafill()


TextBox1.Text =




""

TextBox2.Text =




""

TextBox1.Enabled =




False

TextBox2.Enabled =




False

Button4.Enabled =




False






Else

MsgBox(




"remplir les deux champs"
, MsgBoxStyle.OkOnly,

"Attention"
)


End



If






End



If






End



Sub
3
Rejoignez-nous