Jump to content
Xtreme .Net Talk

Recommended Posts

Guest boskomihic
Posted

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?

Guest zigona
Posted
Silly, but maybe it doesn't meet the criteria (doesn't find the ID).
Guest boskomihic
Posted

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:

Guest boskomihic
Posted

This query works fine in Microsoft Access.

 

What you meen by that "Normal update query"?

  • *Gurus*
Posted

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.

  • *Gurus*
Posted

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.

Guest boskomihic
Posted

ZIP FILE

 

Here is my project.

You will be enable to press Update Link Label when you make same changes.

Guest boskomihic
Posted
But a normal update query should work, shouldn't it?

 

What is that 'Normal update query'

Can someone send me same example?

Guest boskomihic
Posted
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.

Guest boskomihic
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...