Hy,
Sorry for the poor english...
I was wondering what the best practice for handling data on a winform is.
I would like to use an access database because of the easy and open end at the database reporting side.
True , there is a lot of google stuff available on that topic.
And i tried a great deal of possibilities, butt without a satisfing result.
I had my hope up on LINQ but i searched 6 houres on how to linq with a variable column name for filtering purpose... i found little or nothing on that so i let it be.
I also use the hard coding way with ADO.net as seen bellow. But it is frustrating that when u make a mistake in the sql expression that it still runs and u can loose quite a long time searching for the solution.
I also used the ado.net tableadapters as seen bellow, and like described on msdn .com but when i use the update functionality nothing happens in my db.
-> Yes i have a primary key in my table...
I would appreciate some guidance and experiances...
Thanks in advance, best regards.
Mathias
What I have tried:
- LINQ
- ADO.net hard coding
- TABLEADAPTERS
Try
Dim strSQLUPDATE As String = "UPDATE " & strTABEL & " SET NAAM = @NAAM ,POSTCODE = @POSTCODE, STRAAT = @ADRES, NR = @NR, STAD = @STAD, LAND = @LAND, TEL = @TEL, BTWPLICHTIG = @BTWPLICHTIG, BTWNR = @BTWNR, EMAIL = @EMAIL WHERE KLANTID = @KLANTID"
Dim dbCONNECTION As New OleDbConnection(My.Settings.PRORENTConnectionString)
Dim dbCOMMANDUPDATE As New OleDbCommand(strSQLUPDATE, dbCONNECTION)
dbCONNECTION.Open()
dbCOMMANDUPDATE.Parameters.AddWithValue("@NAAM", NAAM)
dbCOMMANDUPDATE.Parameters.AddWithValue("@POSTCODE", POSTCODE)
dbCOMMANDUPDATE.Parameters.AddWithValue("@ADRES", ADRES)
dbCOMMANDUPDATE.Parameters.AddWithValue("@NR", NR)
dbCOMMANDUPDATE.Parameters.AddWithValue("@STAD", STAD)
dbCOMMANDUPDATE.Parameters.AddWithValue("@LAND", LAND)
dbCOMMANDUPDATE.Parameters.AddWithValue("@TEL", TEL)
dbCOMMANDUPDATE.Parameters.AddWithValue("@BTWPLICHTING", BTWPLICHTING)
dbCOMMANDUPDATE.Parameters.AddWithValue("@BTWNR", BTWNR)
dbCOMMANDUPDATE.Parameters.AddWithValue("@EMAIL", EMAIL)
dbCOMMANDUPDATE.Parameters.AddWithValue("@KLANTID", CustomerId)
dbCOMMANDUPDATE.ExecuteNonQuery()
dbCONNECTION.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
___________ this is the tableadpter update code
Try
Me.Validate()
Me.CustomersBindingSource.EndEdit()
Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
MsgBox("Update successful")
Catch ex As Exception
MsgBox("Update failed")
End Try