A problem of ExecuteReader in asp.net connecting mysql

Last post 02-20-2008 9:21 AM by cheukhanghk. 2 replies.

Sort Posts:

  • A problem of ExecuteReader in asp.net connecting mysql

    02-20-2008, 7:01 AM
    • Member
      point Member
    • cheukhanghk
    • Member since 02-20-2008, 6:56 AM
    • Posts 7
    1    Protected Sub Button1_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles Button1.Click 
    2        Using conn As New Data.SqlClient.SqlConnection(SqlDataSource1.ConnectionString) 
    3            Dim command As New Data.SqlClient.SqlCommand("select name from student where id =123; ", conn) 
    4            conn.Open() 
    5            Dim reader As Data.IDataReader 
    6            reader = command.ExecuteReader() 
    7            While reader.Read() 
    8 
    9 
    10                Dim name As String = reader.GetString(0) 
    11 
    12            End While 
    13            TextBox1.Text = name 
    14        End Using 
    15    End Sub 
    16End Class

     I am a newbie, so there maybe have many erro.....

     Visual Studio tell me the biggest erro on the line 13

     

    13            TextBox1.Text = name 

    but I dont know what wrong it is, can anyone tell me pls?

     
    I am using asp.net connecting mysql
     

  • Re: A problem of ExecuteReader in asp.net connecting mysql

    02-20-2008, 7:52 AM
    Answer
    • Participant
      816 point Participant
    • AndreiH
    • Member since 01-21-2008, 4:04 PM
    • Bucharest
    • Posts 165

    Put Dim name As String on line 3

    Instead of line 10 put:

     name = reader.GetString(0)

    and should work.  

    Best regards,
    Andrei
  • Re: A problem of ExecuteReader in asp.net connecting mysql

    02-20-2008, 9:21 AM
    • Member
      point Member
    • cheukhanghk
    • Member since 02-20-2008, 6:56 AM
    • Posts 7
    AndreiH:

    Put Dim name As String on line 3

    Instead of line 10 put:

     name = reader.GetString(0)

    and should work.  

     

    thank you, I solved the problem!

Page 1 of 1 (3 items)