Visual Studio Upgrade Question 2003-2005 SQLDATAREADER

Please ignore the open questions I have outstanding - those I had to solve on my own
I upgraded from VS.net 2003 to 2005.
Converting code is difficult I am looking for some help.

This code was created in 2003 version of VS - Please help me convert by using 2005 methods

This code is executed on the ZipCode field textchanged event
        SqlConnection1.Open()
        Dim dr As SqlDataReader
        dr = SqlCommand2.ExecuteReader()
        While dr.Read()
            If (dr("ZIPCODE")) = Zip.Text Then
                'fldZip.Text = dr("Zipcode")
                City.Text = UCase(dr("City"))
                State.Text = UCase(dr("State"))
            Else
                'fldCity.Text = ""
                'fldState.Text = ""
            End If
        End While
        dr.Close()
        SqlConnection1.Close()
Dale MassicottePresidentAsked:
Who is Participating?
 
Bob LearnedCommented:
Using connection As New SqlConnection(connectionString)
   connection.Open()
   Using command As New SqlCommand(commandText, connection)
        Using reader As SqlDataReader = command.ExecuteReader()
            Dim table As New DataTable()
            table.Load(reader)
            Dim row As DataRow = table.Rows(0)
            City.Text = row("City").ToString().ToUpper()
            State.State = row("State").ToString().ToUpper()
        End Using
   End Using
End Using

Bob
0
 
Dale MassicottePresidentAuthor Commented:
I will give it a shot right now...thanks for responding TheLearnedOne
0
 
Dale MassicottePresidentAuthor Commented:
I have a couple of problems with the code'

Using connection As New SqlConnection(connectionString)
[connectionstring] not declared - I assume that I enter my own connstr here yes?

Using command As New SqlCommand(commandText, connection)
[commandtext] not declared - that I have no clue

Also....How can I learn this code?  Any good references can u suggest?
0
 
Bob LearnedCommented:
1) You need a connection string, from where ever that you get it.

2) You need a select statement:  Select * From Table1

3) I don't have any specific references for ADO.NET, but you could use Google to look for ADO.NET tutorials.

http://samples.gotdotnet.com/quickstart/howto/doc/adoplus/ADOPlusOverview.aspx

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.