Christineeve
Programmer
Hi,
My experience is with VBA and MS Access.
I'm new to using Table Adapters in VB to consume data in Access. I'm trying to put all this new information in my head so I can move forward to the new technology. I cannot seem get data back from my Select Statement, Insert a row, or update a row I've hard coded.
I think if I could see how it would work in my own code, I could figure out how it works in examples and move forward.
Your help is very much appreciated.
The select statement passes False instead of passing the keyed variable "Christine.Lee".
I have no idea how to do an Insert with this new information.
The Update statement doesn't change keyed variable "Christine.Lee" to the name of the PC from the code.
So, nothing works.
Here's my code:
My experience is with VBA and MS Access.
I'm new to using Table Adapters in VB to consume data in Access. I'm trying to put all this new information in my head so I can move forward to the new technology. I cannot seem get data back from my Select Statement, Insert a row, or update a row I've hard coded.
I think if I could see how it would work in my own code, I could figure out how it works in examples and move forward.
Your help is very much appreciated.
The select statement passes False instead of passing the keyed variable "Christine.Lee".
I have no idea how to do an Insert with this new information.
The Update statement doesn't change keyed variable "Christine.Lee" to the name of the PC from the code.
So, nothing works.
Here's my code:
Code:
Private Sub SelectedMachineName()
'This is a test procedure to understand how to take a variable from our system and manipulate it.
'This procedure extracts the name of the client workstation and updates the table in our Access Database.
Dim CurMachineName
Dim DT As New DataTable
Dim Con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim DA As New OleDb.OleDbDataAdapter
DA.SelectCommand = Cmd
Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Christine Lee\BlahBlah Industries\Project Documents\Database\ClientData.accdb;Persist Security Info=False"
Cmd.Connection = Con
Cmd.CommandType = CommandType.Text
'Get the Machine Name from the selected client.
CurMachineName = System.Environment.MachineName
'Write to the Console for debug--remove.
Console.WriteLine("Machine Name: {0} ", CurMachineName)
'select what is in the database now
Dim strPreview As String = cmd.CommandText = "Select * from tblClient_Machine;"
MsgBox("The value is: " & strPreview)
'Dim strPreview As String
'strPreview just returnes "False" Not the data.
Me.lblPreview.Text = strPreview
'Add INSERT statement here. How do I Insert?
'Update the hardcoded name.
'The Update doesn't take place here either.
cmd.CommandText = "UPDATE tblClient_Machine " & _
" SET pk_ClientWSName= '" & CurMachineName & " ;"