Sending data from text boxes/combo boxes to Access database?
Hi,
I'm in the middle of creating an application that will be used to input customer information whilst the customer is speaking to someone over the phone. This involves the customer giving the employee information such as name, address, postcode etc and the employee inputting that information into text boxes and combo boxes that are in the application.
What I would like to be able to do is after the customers information is given over the phone, I need to be able to send that information to a database which will probably most likely be done by button click. In this case, I'm using Microsoft Access. I'm also hoping that I can do this within Visual Basic coding.
The database is set out with multiple tables which include a customer table and a ticket table and both have multiple fields such as first name, surname in the customers table. Both of these tables are in use with the information that the customer gives over the phone.
I've already asked on other forums and people are where replying giving me third party programs that I could use to implement this, something I don't really want to do.
Hopefully that all makes sense.
Hope someone can help with this.
Thank you in advance.
Chris.
Re: Sending data from text boxes/combo boxes to Access database?
I actually just finished studying this. Here's how you need to code:
Code:
Dim info as datarow
info = Me.YourDataSet.TableName.NewRow()
info.Item("ColumnName") = me.txtFirstName.Text
info.Item("ColumnName") = me.txtLastName.Text
!-- Do the same for all text boxes
me.YourDateSet.TableName.Rows.Add(info)
Me.TableNameTableAdapter.Update(Me.YourDataSet)
You'll first need to know how to connect a database to your application.
LadySylvia
Re: Sending data from text boxes/combo boxes to Access database?
Hi,
Thank you for your reply!
I'm slightly confused about some aspects of the code that you've provided.
Quote:
info = Me.YourDataSet.TableName.NewRow()
In this line of code, am I supposed to add the name of my data set where "YourDataSet" is shown? I've already tried this and it always returns an error.
Quote:
info.Item("ColumnName") = me.txtFirstName.Text
I don't understand what I'm supposed to input into the "me.txtFirstName"? Do I input a column name or something database related?
Also, in "ColumnName", do I simply just input the name of the column in the database?
Sorry if this is slightly annoying.
Thank you again!
Re: Sending data from text boxes/combo boxes to Access database?
info = Me.YourDataSet.TableName.NewRow()
you put the name of your dataset and the name of the table
info.Item("ColumnName") = me.txtFirstName.Text
put the name of the column in quotes = is the textbox where your firstname is
hope that helps
Re: Sending data from text boxes/combo boxes to Access database?
Quote:
Originally Posted by
billboy
info = Me.YourDataSet.TableName.NewRow()
you put the name of your dataset and the name of the table
info.Item("ColumnName") = me.txtFirstName.Text
put the name of the column in quotes = is the textbox where your firstname is
hope that helps
After I input the code I get multiple errors relating to the data sets code.
I'm referring to the customers data set in this example as I'll be updating customer records when the 'Send to database' button is clicked. The code I've input is below.
Dim info As DataRow
info = Me.CustomersDataSet.customers.NewRow()
info.Item("forename") = Me.txtForename.Text
info.Item("surname") = Me.txtSurname.Text
Me.CustomersDataSet.customers.Rows.Add(info)
Me.CustomersTableAdapter.Update(Me.CustomersDataSet)
Errors are shown in italics here.
Re: Sending data from text boxes/combo boxes to Access database?
Quote:
Originally Posted by
chrismid259
After I input the code I get multiple errors relating to the data sets code.
I'm referring to the customers data set in this example as I'll be updating customer records when the 'Send to database' button is clicked. The code I've input is below.
Dim info As DataRow
info = Me.CustomersDataSet.customers.NewRow()
info.Item("forename") = Me.txtForename.Text
info.Item("surname") = Me.txtSurname.Text
Me.CustomersDataSet.customers.Rows.Add(info)
Me.CustomersTableAdapter.Update(Me.CustomersDataSet)
Errors are shown in italics here.
Need to see all the code for this I was answering the specific question about what went where yourdataset and textbox
Re: Sending data from text boxes/combo boxes to Access database?
I'm wondering two things: did you connect the data source to the application?
and what type of system do you have?
you might be getting the same errors I had when I started in vb.
Re: Sending data from text boxes/combo boxes to Access database?
download my book it has walkthroughs about using ms access databases in vb.net
Re: Sending data from text boxes/combo boxes to Access database?
Quote:
Originally Posted by
LadySylvia
I'm wondering two things: did you connect the data source to the application?
and what type of system do you have?
you might be getting the same errors I had when I started in vb.
Yes, I believe I have connected the data source to my application. Not sure what you mean by what system I have.
Quote:
Originally Posted by
billboy
Need to see all the code for this I was answering the specific question about what went where yourdataset and textbox
The code I posted here previously is all the code I have for this form at the moment.
Re: Sending data from text boxes/combo boxes to Access database?