locked
VB.net & sqlserver RRS feed

  • Question

  • HOW TO  CELL VALUE FILL CORRESPONDING CELL IN ROW FROM DATABASE VB.NET ?

    Tuesday, December 2, 2014 1:32 PM

Answers

All replies

  •   Dim connetionString As String
            Dim connection As SqlConnection
            Dim command As SqlCommand
            Dim sql As String
            connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
            sql = "Your SQL Statement Here ,  like Select * from product"
            connection = New SqlConnection(connetionString)
            Try
                connection.Open()
                command = New SqlCommand(sql, connection)
                Dim sqlReader As SqlDataReader = command.ExecuteReader()
                While sqlReader.Read()
                    MsgBox(sqlReader.Item(0) & "  -  " & sqlReader.Item(1) & "  -  " & sqlReader.Item(2))
                End While
                sqlReader.Close()
                command.Dispose()
                connection.Close()
            Catch ex As Exception
                MsgBox("Can not open connection ! ")
            End Try

    Tuesday, December 2, 2014 1:43 PM
  • Can you clarify the question (please use Bing or Google translator before you post the question).
    I did not understand what you asked :-(

    signature   Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

    Wednesday, December 3, 2014 1:55 AM
  • Hi Elango,

    For such issues about VB.NET programming, I would like to recommend you post the question in the Visual Basic forum at https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral . It is appropriate and more experts will assist you.

    Thanks,
    Lydia Zhang

    • Proposed as answer by Saeid Hasani Saturday, December 6, 2014 8:34 PM
    • Marked as answer by pituachMVP Tuesday, December 9, 2014 8:32 AM
    Wednesday, December 3, 2014 9:03 AM