Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

this is what i have so far for updaing one column but i need to update multiple columns in my form

 

Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yada_yada_yada.mdb")

MyConnection.Open

Dim MyCommand As New OleDbCommand("UPDATE Cust SET Fname = me.txtFname.text WHERE ID = txtUpdID", MyConnection)

MyCommand.ExecuteNonQuery()

MyConnection.Close

MyReader.Close

MyCommand.Dispose

 

 

anyway how would i go about doing an update for lets say

SET Fname = me.txtFname.text, Lname = me.txtLname.text, Mname = me.txtMname.text WHERE ID = me.txtUpdID;

 

i have been searching for some kind of code showing this but my searches come up NULL :(

Posted

OK i have made pretty good headway but now my execution button fails. what i have done is populated the textboxes by the row PK "ID" i now want to update that data that data that is presented

 

here is my commit change button code

 

Dim myCmd As New OleDb.OleDbCommand("UPDATE phonesOHM SET Name = " & Me.txtUpdName.Text & _

" ,Address = " & Me.txtUpdAddress.Text & _

" ,City = " & Me.txtUpdCity.Text & _

" ,State = " & Me.txtUpdState.Text & _

" ,Zip = " & Me.txtUpdZip.Text & _

" ,Phone = " & Me.txtUpdPhone.Text & "," & _

"WHERE ID = " & Me.txtUpdID.Text, myCnn)

 

 

myCmd.ExecuteNonQuery()

myCnn.Close()

myCmd.Dispose()

 

all of the data is properly collected i just dont think its sending it right back to access. any ideas? i think i'm having problems when i open and close the connections for the "populate button"?

Posted

nevermind I got it.

 

well I figured it out. If anybody was wondering the code for multiple column updates in a single row is.....

 

well first populate the textboxes with a simple select query

then.....

 

Private Sub btnUpdCommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdCommit.Click

 

Dim myCnn As New OleDb.OleDbConnection

 

If myCnn.State = ConnectionState.Open Then

myCnn.Close()

End If

Dim mysql As String

myCnn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=C:\Company\CompanyXP.mdb"

myCnn.Open()

 

 

 

Dim myCmd As New OleDb.OleDbCommand("UPDATE phonesOHM SET Name = '" & Me.txtUpdName.Text & "' ,Address = '" & Me.txtUpdAddress.Text & "' ,City = '" & Me.txtUpdCity.Text & "' ,State = '" & Me.txtUpdState.Text & "' ,Zip = '" & Me.txtUpdZip.Text & "' ,Phone = '" & Me.txtUpdPhone.Text & "' WHERE ID = " & CInt(Me.txtUpdID.Text), myCnn)

 

Try

myCmd.ExecuteNonQuery()

myCnn.Close()

myCmd.Dispose()

Catch ex As Exception

MsgBox("error! error! w00t! w00t!: " & vbCrLf & ex.Message)

End Try

End Sub

 

-JB

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...