Save in database didn't work ?! (VB.NET | OLE) -
I use the following code to edit the user, the code does not give me an error code, but at the same time It does not work anymore, the data are still without any new changes:
dim an a string A = combo 3 Text & amp; "/" & Amp; Comb2.Text & amp; "/" & Amp; Comb1.Text Dim SavInto New OleDb.OleDbCommand Dim ConStr as string = _ "Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" & amp; _Application Startup path & amp; "\ Base.mdb" New OleadBConnect (Concert) Conn. Open () Sevinato.connection = ConSavinO Type Commands = CommandType Text Softino Common Text = "Update TB Sts Tasalsol = '" & amp; _ Trim (frm.tx1.Text) & amp; _ "', Enamor ='" & amp; Trim (frm.TextBox2.Text) & amp; _ "', Name =' '& amp; trim (frm.tx3.Text) & amp; _"', rotba = '& amp; Trim (frm.tx4.Text) & amp; _ "', Space ='" & amp; Trim (frm.tx5.Text) & amp; _ "', End-current ='" & amp; A & amp; _ "'WHERE notes ='" & amp; Trim (frm.tx8.Text) & amp; "'" SavInto.ExecuteNonQuery () Conn.Close () frm .tx1.Text = Me.tx1.Text with TextBox2.Text = Me.tx2.Text .tx3.Text = Me.tx3.Text .tx4.Text = Me.tx4.Text .tx5.Text = Me.tx5.Text. Tx6.Text = One. Tx8.Text = Me.tx8.Text end frm.Show () with Me.Close ()
I wrote the whole code, what is wrong with ?! And thanks
Note : There are some columns that can have a lot of data in its cells
Intelligent advice about using a parameterized query instead of lot where the section looks very strange, you really want to make sure Want to use the "Notes" field to update a row? And tx8
is an editable field? Why are you triming it? It seems that the best way to find the line to update is through a field called "Notes", which appears plain text that requires trim.
It is better to use the ID of the question (or rows) to update this lot .
Note that you are not seeing the return value of ExecuteNonQuery
- I suspect that it will return 0 to indicate that it does not update any rows. He should check that.
In addition, you should use the use
statement for both connections and commands, so that they can be dealt with properly and the exception is also thrown.
Just to repeat: Please, please use parameteric queries instead of embedding values in SQL such questions like DBA cry.
Comments
Post a Comment