I've been looking everywhere for an answer to a simple question, but i'm having issues, so i thought i'd join and post here.
I'm having issues with a simple concept. I load information from a SQL database, and i want to add a 'Passport' link URL relating to column cells called 'name'. It basically selects the name, and inserts it into the link fields to be opened. But i cant find a way to work it.
I thought i could do it with something like:

Public Shared Sub retriveDataToDataGrid()        
Dim names() As String
        Try
            Dim lnk As New DataGridViewLinkColumn()
            Dim query As String = "SELECT * FROM data"
            Dim connection As New MySqlConnection(connStr)
            Dim da As New MySqlDataAdapter(query, connection)
            Dim ds As New DataSet()
            If da.Fill(ds) Then
                Form2.DataGridView1.DataSource = ds.Tables(0)
                Form2.DataGridView1.Columns.Add(lnk)
                For x = 0 To Form2.DataGridView1.Rows.Count - 1
                    names(x) = Convert.ToString(Form2.DataGridView1.Item(2, x).Value)
                    lnk.Text = "C:\" & names(x)".jpg"
                Next x
                lnk.HeaderText = "Passport"
                lnk.UseColumnTextForLinkValue = True
            End If
            connection.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

But i thought wrong and i'm getting null exceptions from the loop.
How could i do this (is there another way)?
Thanks for help in advance.

Try this:

c.con.open()
dim cmd as new sqlcommand("select * from users",c.con)
cmd.executereader()
if(read()) then
textbox1.text=dr(name).tostring()
end if
c.con.close()

c & con is an object of class and connection respectively.
textbox1.text is the name of field in which you want to retrieve data from your database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.