473,386 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

auto populate this textbox using vb.net

hello guys

Im trying to autopopulate my form from a table in my database called Enrollment.it will fill the textboxes in my form whenever the id number typed in the textbox is existing in my database.. the selection will be based in the highest EnrollmentID whatever is the highest EnrollmentID that matches with id number will automatically fill the textboxes. i put these code inside my idnumber textbox by double clicking it. can somebody help me please...


i need all the advice that you can give me..

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub populate()
  3.         Dim xx As DataTable
  4.  
  5.  
  6.         xx = db1.doQuery("select idno from Enrollment where idno='" + Me.txtidno.Text + "'")
  7.         If xx.Rows.Count <> 0 Then
  8.  
  9.             xx = db1.doQuery("select Firstname, Middlename, Lastname, level1, preschoollevel,primarylevel,secondarylevel,tuitionfee, amountpaid,tobwithd,tobwithoutd from Enrollment where Firstname='" + Me.txtfirstname.Text + "', Middlename='" + Me.txtmi.Text + "', Lastname='" + Me.txtlastname.Text + "', level1 = '" + Me.ComboBox1.Text + "', preschoollevel='" + Me.cmbpreschool.Text + "', primarylevel='" + Me.cmbprimary.Text + "', secondarylevel ='" + Me.cmbsecondary.Text + "', tuitionfee='" + Me.TextBox5.Text + "', amountpaid ='" + Me.txtpreviousamountpaid.Text + "', tobwithd= '" + Me.txtbal.Text + "', tobwithoutd = '" + Me.txtbal.Text + "'")
Nov 15 '07 #1
5 3420
Shashi Sadasivan
1,435 Expert 1GB
Do you want to populate a datagridview?
or details view?

In Short, how do you want your data to be shown on the form?
You just cant put it there, can you?
Nov 15 '07 #2
Do you want to autopopulate only the textboxes as seen in your code then you just need to call the event automatically every time the id is entered by using the onblur event of the ID textbox.
Nov 15 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
and change the comma in the sql string to AND

sql syntax is usually
Expand|Select|Wrap|Line Numbers
  1. Select * from tableName where field1 = value1 and field2 = value2
and not
Expand|Select|Wrap|Line Numbers
  1. Select * from tableName where field1 = value1 ,field2 = value2
Nov 15 '07 #4
debasisdas
8,127 Expert 4TB
You need to populate the data in the textbox from database.
Nov 15 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
are you using any sort of typed datasets?
in that case drag the fields from the data source view to your form.

and you would not have to do anything else

only if this is in windows forms
Nov 15 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: C. David Rossen | last post by:
Hello: I have a registration form for classes. Each class has a fee. I have a drop down box whereby the user chooses his class. There is a textbox with the associated fee. I would like to...
2
by: Mark | last post by:
I am attempting to populate several textbox controls from VBA code. With each attempt, I get the following error: "The macro or function set to the BeforeUpdate or ValidationRule property for...
0
by: Alex Moskalyuk | last post by:
I am using System.Windows.Forms.TextBox to publish some real-time data that's coming off the external devices. My data is fed into the TextBox with proper precautions not to exceed the MaxSize...
6
by: Smithers | last post by:
I am looking to implement a search feature into a Windows Forms MDI application. Specifically I plan to embed 3 textboxes into a toolbar; one for LastName, another for FirstName, and one for...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
1
by: Jim | last post by:
I have a new database in which I have a form where in one field I type a letter A, B, C or D and the field next to it autofills (auto lookups) with a description associated with the specific...
2
by: keri | last post by:
Hi, I'm still struggling with my tables - frustrating. If a field in table one is completed I want the following field to auto populate (dependng on the answer to the first field). I have...
11
by: eureka | last post by:
Hi All, I'm training in Servlets, JSP and JavaScript, I have a web page in which there's a "StudentName" textbox and below it is a "Names" Dropdown list. Initially the Textbox is empty and...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.