Guest boskomihic Posted August 10, 2002 Posted August 10, 2002 Dim cn As New OleDb.OleDbConnection() Dim cm As New OleDb.OleDbCommand() cn.ConnectionString = _ "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=D:\My Documents\Visual Studio Projects\Adresar\Adresar.mdb;Mode=ReadWrite" Try cn.Open() cm.Connection = cn cm.CommandText = "UPDATE Podaci SET Podaci.Ime = [@Ime], Podaci.Prezime = [@Prezime], Podaci.Datum = [@Datum], Podaci.Adresa = [@Adresa], Podaci.Fixni = [@Fixni], " & _ "Podaci.Mobilni = [@Mobilni], Podaci.Email = [@Email], Podaci.Home = [@Home], Podaci.Slika1 = [@Slika1], Podaci.Slika2 = [@Slika2], Podaci.[Note] = [@Note] WHERE (((Podaci.ID)=[@ID]));" cm.Parameters.Add(New OleDb.OleDbParameter("@ID", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Ime", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Prezime", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Datum", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Adresa", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Fixni", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Mobilni", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Email", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Home", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Slika1", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Slika2", OleDb.OleDbType.VarChar)) cm.Parameters.Add(New OleDb.OleDbParameter("@Note", OleDb.OleDbType.VarChar)) cm.Parameters("@ID").Value = EditID cm.Parameters("@Ime").Value = txtIme.Text Debug.WriteLine(txtIme.Text) cm.Parameters("@Prezime").Value = txtPrezime.Text cm.Parameters("@Datum").Value = txtDatum.Text cm.Parameters("@Adresa").Value = txtAdresa.Text cm.Parameters("@Fixni").Value = txtFixni.Text cm.Parameters("@Mobilni").Value = txtMobilni.Text cm.Parameters("@Email").Value = llblEMail.Text cm.Parameters("@Home").Value = llblWeb.Text cm.Parameters("@Slika1").Value = pic1.Text cm.Parameters("@Slika2").Value = pic2.Text cm.Parameters("@Note").Value = txtNote.Text cm.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.ToString) Finally cn.Close() End Try This is my update code. But, even if I don't get any error message, this code doesn't work anything (everything stays same). Why? What's wrong? Quote
Guest zigona Posted August 11, 2002 Posted August 11, 2002 Silly, but maybe it doesn't meet the criteria (doesn't find the ID). Quote
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 It�s not problem in that. I used debug.writeline(EditID) to get shore that ID is valid but everything seems o be fine there. :( :( :( :confused: Quote
Flyguy Posted August 12, 2002 Posted August 12, 2002 Are you sure you need this complex way to do an update? I mean using all these @ variables? Why not perform a normal SQL update query? Quote
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 This query works fine in Microsoft Access. What you meen by that "Normal update query"? Quote
*Gurus* Thinker Posted August 12, 2002 *Gurus* Posted August 12, 2002 Since this is ADO.Net, none of us really understand what is going to make this work. In standard ADO with Access, this would require using ADOX to use an Update Query as a stored proc. I have no idea what is involved with ADO.Net. I am moving this to the ADO.Net forum. Quote Posting Guidelines
Flyguy Posted August 12, 2002 Posted August 12, 2002 Is this to create a table or new fields in a table on the fly OR is it just for updating data? Quote
*Gurus* Thinker Posted August 12, 2002 *Gurus* Posted August 12, 2002 If I am reading it correctly, it is to pass parameters to an update query in Access. Quote Posting Guidelines
Flyguy Posted August 12, 2002 Posted August 12, 2002 But a normal update query should work, shouldn't it? Quote
*Gurus* Thinker Posted August 12, 2002 *Gurus* Posted August 12, 2002 A normal update SQL should work. I just assumed the question was how to use an Access update Query with ADO.Net. Using Queries is about as close to using a stored proc in SQL Server as you can get in Access, so it is a good idea if one is considering upgrading the all to SQL Server down the road, or wants to have versions for both and change the least code. Quote Posting Guidelines
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 ZIP FILE Here is my project. You will be enable to press Update Link Label when you make same changes. Quote
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 But a normal update query should work, shouldn't it? What is that 'Normal update query' Can someone send me same example? Quote
*Gurus* Thinker Posted August 12, 2002 *Gurus* Posted August 12, 2002 I assume Arnout is referring to an SQL Update statement. Update TableName Set field1='value1', field2='value2', ... Where primarykeyfield = 'keyvalue' Quote Posting Guidelines
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 If I am reading it correctly, it is to pass parameters to an update query in Access. No it's not. I'm just saying that when I copy this sql query to Access and start it, it work normal. Quote
Guest boskomihic Posted August 12, 2002 Posted August 12, 2002 I assume Arnout is referring to an SQL Update statement. Update TableName Set field1='value1', field2='value2', ... Where primarykeyfield = 'keyvalue' But that's same I tried on that way, but when I didn�t success I decide to make a query using Microsoft Access. And when i made it, I just copied it in VB.NET I send an example and you will see all there. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.