working with record sets.

Last post 10-20-2009 2:48 PM by Mikesdotnetting. 1 replies.

Sort Posts:

  • working with record sets.

    10-20-2009, 1:05 PM
    • Member
      2 point Member
    • sva0008
    • Member since 07-02-2009, 5:20 PM
    • Posts 23

    Hi , i am new to vb.net can anyone help me how to use recordset in vb.net.
    Basically this is the asp code and i want to do this in vb.net.

    sql = " select * from product "
    rs.open sql, conn


    while not rs.eof do
        productname  = rs("ProductName")
       Id  = rs ("productId")
    rs.Movenext
    loop


    Regards


  • Re: working with record sets.

    10-20-2009, 2:48 PM
    Answer

    For Sql Server:

    Dim ConnString As String = <Your Connection String>
    Dim ProductName As String
    Dim Id As Integer
    Dim Sql As String = "Select * From Products"
    Using conn As New SqlConnection(ConnString)
      Using cmd As New SqlCommand(Sql, conn)
        cmd.CommandType = CommandType.Text
        conn.Open()
        Using reader As SqlDataReader = cmd.ExecuteReader()
          While reader.Read()
            ProductName = reader("ProductName")
            Id = reader("ProductID")
          End While
        End Using
      End Using
    End Using


    Regards Mike
    [MVP - ASP/ASP.NET]
    My site    Please help - URGENT!!!    What ASP.NET can and can't do
Page 1 of 1 (2 items)