Jump to content
Xtreme .Net Talk

dakota97

Avatar/Signature
  • Posts

    116
  • Joined

  • Last visited

Everything posted by dakota97

  1. One last quick thing. How would I insert the system time into the StartTime field using my code?
  2. Finally it worked. Thanks for all your help techmanbd. Like this post says, it was driving me crazy, and as usual it was something small and stupid. Oh well. Thanks again, Chris
  3. Everything checks out. Attached here is a copy of the entire solution including the database, which is inside the BIN folder. Thanks for all of the suggestions and help from everyone so far. edit: removed binaries timeclock.zip
  4. Ok. Still getting error. This is the code that I have: Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= timeclock.mdb") MyConnection.Open() Dim MyCommand As New OleDbCommand("INSERT Into EmpHours (EmpID, StartTime, EndTime) VALUES ('chris','adam','alex');", MyConnection) MyCommand.ExecuteNonQuery() And this is the exact error that I'm getting: An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
  5. I did, and I got an error in the syntax after the comma immediately following EmpHours.EmpID in the following statement: INSERT Into EmpHours.EmpID, EmpHours.StartTime, EmpHours.EndTime VALUES ('chris','adam','alex');
  6. I tried taking out the textboxes and just putting in data (e.g. VALUES ('Chris','Adam','Andy')), but that didn't work either. I just don't understand why it worked on my form to add the employees information, but it won't work on this form
  7. Ok, but the code in my last post is the one that works. The code that doesn't work is in my first post
  8. They are both text fields, which is why it doesn't make any sense. Like I said, I used the same exact code on my form to add the employee information to the database, and it worked fine. I just changed the amount of fields in the SQL. Here's a copy of the code for that connection: Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= timeclock.mdb") MyConnection.Open() Dim MyCommand2 As New OleDbCommand("INSERT Into Employees VALUES ('" & TextBox15.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox11.Text & "','" & TextBox12.Text & "','" & TextBox13.Text & "','" & TextBox14.Text & "','" & ComboBox1.Text & "')", MyConnection) Dim AddCust As OleDbDataReader = MyCommand2.ExecuteScalar()
  9. The last line where it executes the SQL is where I get the error. It just says unhandled exception, and when I stop debugging it highlights the last line that I pasted
  10. Hi all, Ok, I've got a problem somewhere in my SQL that inserts a record into my Access DB. I've used the same code before for the connection and inserting a record into another table, but for some stupid reason this one won't work. I keep getting an unhandled exception in the following code: Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= timeclock.mdb") MyConnection.Open() Dim MyCommand As New OleDbCommand("INSERT Into EmpHours (EmpID, StartTime, EndTime) VALUES ('" & TextBox1.Text & "','" & TextBox1.Text & "','" & TextBox1.Text & "')", MyConnection) MyCommand.ExecuteScalar() The only reason I have it inserting textbox1.text in all the fields is for testing purposes, and so far nothing has worked. Anyone has any ideas? The table only has 3 fields (EmpID, StartTime, EndTime) and all 3 are set to text data types. Thanks in advance, Chris
  11. Hi all, I'm having trouble retrieving a record from the DB and displaying the field in a textbox. I want to type a customers phone number in textbox1 and then search the DB for a matching record and display the information in tebox2 For some reason it won't display anything in the textbox2 when I click the button. Here's my code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= pos.mdb") MyConnection.Open() Dim MyCommand As New OleDbCommand("SELECT * FROM Customers WHERE Phone LIKE'" & TextBox1.Text & "'", MyConnection) Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader() While MyReader.Read TextBox2.Text = MyReader("Name") End While End Sub Thanks in advance, Chris
  12. BTW...here's my original code from when I attempted to use a listbox to display the items. Keep in mind that I am a newbie, and I'm trying to make sense of all of this. I have experience in ASP, but VB.Net is a little different. Maybe if you look at my code you'll see what I'm trying to accomplish. Thanks in advance, Chris pos.zip
  13. Hi all, I'm a newbie with a question about datagrids. What I'm trying to do is create a cash register program. So far from my previous posts, I'm come to the conclusion that adding a datagrid is the best way to keep track of the customers items and prices. My question is, how can I add one single record to the datagrid when the user enters a purchased item? I have a textbox for the user to enter an item number (e.g. item # 1-001), and a button to pull the specific record matching that number from the database. Let's say I just want to display the description, price, and quantity in the datagrid. How do I do this so that only that particular record is displayed? Thanks in advance, Chris
  14. Thanks for the quick reply. Ok, I see understand what you mean as far as using the datagrid. My question is how can I add just one result to the grid? All of the post that I've come across describe how to populate a datagrid with all records in a table. I was however able to add a record to a listbox. What I came up with was using 3 listboxes to show the information. Is it possible to get a sum of the items in the PRICE listbox and display them in the SUBTOTAL textbox?
  15. Hi all, I'm relatively new to VB.Net and I'm runing into a problem. I'm trying to create a cash register program that allows the user to type an item number into a textbox, click a button, and have the matching database record be populated in a listbox. Am I using the right control as far as using a listbox, or should I use something else? Afterwards I'll need to add more items to the listbox and calculate the total. Thanks in advance, Chris
  16. Hi all, I'm relatively new to VB.Net and I'm runing into a problem. I'm trying to create a cash register program that allows the user to type an item number into a textbox, click a button, and have the matching database record be populated in a listbox. First question, am I using the right control as far as using a listbox, or should I use something else? Afterwards I'll need to add more items to the listbox and calculate the total. Second question, I've tried a few sample codes that connect to the DB and pull the right record based on a query, but apparently the connection is closing before it gets to the point to display the record. Any help would be greatly appreciated. Thanks in advance, Chris
×
×
  • Create New...