Hi, i am developing a software using microsoft visual studio basic 2010.

I used a datagridviewcontrol to display a list of data from product table.

What I want to do (actually i am not sure how to do it, or is there a way to do it), when i choose one of the value in one of the column inside the table, i want it to open a form that contain data(details) based on that value.
How to do it?
how to call the value that I pressed, so it can be used to open a new form containing the details of that value

example of the data: (the "system" column)
SYSTEM
topaz
nex1300
Nec

If i pressed "topaz" system, it will prompt me to a new form containing the details of that "topaz" system.

Please help me

str=DataGridView1.SelectedCells(0).Value.ToString()
 if str="topaz" Then
    //open topaz form
 end if

Thanks for that. I have another problem.

let say --> "str" is the value that i clicked on the first form

In the new form, there will be a datagridview controler that contains the detail about the value from str.

I want to display the detail in the datagridview using querybuilder. I want to pass this str to the WHERE clause.

let's say, this will be in my code for displaying the detail of str.
SELECT * FROM tblProduct
where SYSTEM = "str" --> the value that i clicked

how can i do it??

And i am not sure whether we can build the data in the datagridview using sql code in the code page.
Because i always use the wizard to build one.
can you please assist me?

thanks

Declare str as static/shared and use it anywhere within the program.

public Module MyMod
   public Str as String
 End Module

OR

public class Test
    public Shared Str as String
End Class

Thanks!

I have problem with generating the data in datagridview controler using code builder, can you please assist me?
this is my code:

Dim SQLConn As New SqlConnection()
Dim SQLCmd As New SqlCommand()

SQLConn.ConnectionString = "Data Source=------;Initial Catalog=-----;Integrated Security=True"
SQLConn.Open() 'Open the connection

SQLCmd.Connection = SQLConn
SQLCmd.CommandText = "SELECT * FROM tblPRODUCT WHERE actualid = 'Form1.str'" -->is it true like this? it does not want to work
Dim SQLdr As SqlDataReader = SQLCmd.ExecuteReader

While SQLdr.Read()
' i guess this will contain the code to load the output query in the datagridview, but i am not sure how to do this, can you please assist me? let say the datagridview controller name is dataGridView1
End While

SQLdr.Close()
SQLConn.Close()

Thanks a lot

SQLCmd.CommandText = "SELECT * FROM tblPRODUCT WHERE actualid = '" & Form1.str & "'"

Thanks!

last question, how to load the output query in the datagridview?
this is my code, and it did not work:

Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim SQLConn As New SqlConnection()
        Dim SQLCmd As New SqlCommand()

        SQLConn.ConnectionString = "Data Source=----;Initial Catalog=----;Integrated Security=True"
        SQLConn.Open() 'Open the connection

        SQLCmd.Connection = SQLConn
        SQLCmd.CommandText = "SELECT p.ACTUALID, p.DESCRIPTION, p.FAMILY, p.PRODUCTGROUP, p.PRICE FROM PRODUCT p LEFT JOIN PRODUCTSYSTEMCONFIG ps ON p.ACTUALID = ps.ACTUALID WHERE ps.SYSTEM = '" & Form1.str & "'"
        Dim SQLdr As SqlDataReader = SQLCmd.ExecuteReader

        While SQLdr.Read()
            DataGridView1.DataSource = SQLdr.Read()
        End While

        SQLdr.Close()
        SQLConn.Close()
    End Sub

The form will load with empty datagridview.

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.