Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 7th, 2006, 06:01 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populating a textbox using results of a query

Trying to do something that seems like it should be really simple, but I'm new to VB (All my development has been asp). I have a form with 4 text boxes: Quantity, Sku, Description, Week, Year.

The user enters the quantity, then the sku. As soon as they leave the sku field, I want to look up the description from a table in the database and place it in the Description field, they then enter the week and year, and upon clicking a button, everything is added to a different table in the database.

It seems like it should be an easy thing to fire a stored procedure once the focus goes on the description box,(taking a parameter from the sku field and looking up the description) and throwing the result into the description textbox, but I can't figure out how to do it yet. I'm sure I'll figure it out, but it's really frustrating to find my way around in this new environment.

 
Old December 7th, 2006, 08:51 PM
Authorized User
 
Join Date: Aug 2006
Location: Charlotte, NC, USA.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubisascends
Default

imports system.data.oledb
Public Class Form1

Dim theCommand as new oledbCommand
Dim theConnection as new oledbConnection
Dim teQuery as String

Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus

theConnection.connectionstring = [connectin string as a string value]

theCommand = new oledbcommand(theQuery, theConnection)

theCommand.Connection.open()

Dim reader as oledbdatareader = theCommand.executereader(commandbehavior.singlerow )

reader.read()

textbox1.text = reader(0)

theCommand.Connection.Close()

end sub

End Class

hope this helps.

Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.
Albert Einstein
US (German-born) physicist (1879 - 1955)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating Fields from a textbox teddyk ASP.NET 2.0 Basics 1 August 8th, 2008 06:25 AM
populating table from a subform based on a query bjcountry Access 1 April 11th, 2008 06:35 AM
Edit Query Results in Results Grid druid2112 SQL Server 2005 1 June 28th, 2007 08:49 AM
different results were given for the same query madhusrp SQL Server 2000 2 May 9th, 2006 01:54 AM
Crosstab query with no results edubbelaar Access 0 November 22nd, 2004 06:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.