hassanintern
New member
- Joined
- Jun 4, 2013
- Messages
- 4
- Programming Experience
- Beginner
Hi,
I am new to sql database so dont know much about it. I have 2 tables in database: Document table(docID;DocDescription are 2 columns) and Version table(docID; VersionName).
one document can have multiple versions of it.
so one docID can have multiple rows in Version table with same docID.
i want to populate dgv2 with a row-click-event of dgv1 which is already populated with DocumentTable. I only want to populate corresponding versions to that docID and i know i need to use WHERE clause but i dont know how to put in code: if someone can write one line, it will be great and explain it.
the code to populate:
Public Sub loadingVersions()
Dim adapter As New SqlDataAdapter()
Dim ds As New DataSet()
Dim con As New SqlConnection("Data Source=it7\SQLEXPRESS2012;Initial Catalog=DocumentManager;Integrated Security=True")
Dim cmd As SqlCommand = con.CreateCommand()
cmd.CommandText = "SELECT VersionName FROM Version WHERE docID = ??????????????"
adapter.SelectCommand = cmd
con.Open()
adapter.Fill(ds, "Version")
con.Close()
DataGridView2.DataSource = ds
DataGridView2.DataMember = "Version"
End Sub
I am new to sql database so dont know much about it. I have 2 tables in database: Document table(docID;DocDescription are 2 columns) and Version table(docID; VersionName).
one document can have multiple versions of it.
so one docID can have multiple rows in Version table with same docID.
i want to populate dgv2 with a row-click-event of dgv1 which is already populated with DocumentTable. I only want to populate corresponding versions to that docID and i know i need to use WHERE clause but i dont know how to put in code: if someone can write one line, it will be great and explain it.
the code to populate:
Public Sub loadingVersions()
Dim adapter As New SqlDataAdapter()
Dim ds As New DataSet()
Dim con As New SqlConnection("Data Source=it7\SQLEXPRESS2012;Initial Catalog=DocumentManager;Integrated Security=True")
Dim cmd As SqlCommand = con.CreateCommand()
cmd.CommandText = "SELECT VersionName FROM Version WHERE docID = ??????????????"
adapter.SelectCommand = cmd
con.Open()
adapter.Fill(ds, "Version")
con.Close()
DataGridView2.DataSource = ds
DataGridView2.DataMember = "Version"
End Sub