Sql - fill textboxes

Posted on 2006-05-05
Last Modified: 2010-04-23
I want to use retreive a record by providing a requested number in   txtTranNumber.text  and then the selected row is to be filled in in txtAddress and txtCityState. How can I accomplish this?  This is the code I have come up so far.



Dim Conn As SqlConnection = New SqlConnection("workstation id=""just a test"";packet size=1000;user id=userx;data source=just a test" & _

"ist security info=True;initial catalog=Results;password=just a test")

Dim StrCommand As String = " Select address, citystate from results where transno = " ' " & Me.txtTrannumber.Text & " ' "

Dim MyCommand As New SqlCommand(StrCommand, Conn)




Catch ex As SqlException


End Try
Question by:VBdotnet2005
    LVL 52

    Expert Comment

    by:Carl Tawn

    This is a duplicate of your question in the ASP.Net topic area. Should request to have one of these questions deleted or changed to point to the other.
    LVL 35

    Accepted Solution

    replace this line



    Dim dr as SqlDataReader

    While dr.Read
    End while

    MyCommand.ExecuteNonQuery() would execute INSERT, UPDATE, or DELETE queries and not used with SELECT

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video discusses moving either the default database or any database to a new volume.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now