how can i select two tables in a datagride [modified]
-
cmd.CommandText = "select * from reglz where fatrname LIKE '%" & TextBox1.Text & "%' " DataGridView1.Refresh() ad.SelectCommand = cmd ad.Fill(ds, "reglz") DataGridView1.DataSource = ds.Tables("reglz") this code for the table that called reglz what i want to do is how can i make this sql statement on 2 tables together at the same time in a datagride in other words i wanna see the 2 tables in the datagride with me condition that i have made in sql statement in reglz which is (where fatrname LIKE '%" & TextBox1.Text & "%' ") then i want to save another word instead of the current one in database and here my working code Dim x As String x = "'" & TextBox2.Text & "'" Call conn() cmd.CommandText = "update reglz set fatrname = " & x & " where fatrname LIKE '%" & TextBox1.Text & "%' " DataGridView1.Refresh() ad.SelectCommand = cmd ad.Fill(ds, "dd") DataGridView1.DataSource = ds.Tables("dd") but how can i apply this code to the 2 table SO what i want is :- how can i select 2 tables to show them in a datagrid how can i save any word for the two tables accroding to my condition . plz help me and thanks
-
cmd.CommandText = "select * from reglz where fatrname LIKE '%" & TextBox1.Text & "%' " DataGridView1.Refresh() ad.SelectCommand = cmd ad.Fill(ds, "reglz") DataGridView1.DataSource = ds.Tables("reglz") this code for the table that called reglz what i want to do is how can i make this sql statement on 2 tables together at the same time in a datagride in other words i wanna see the 2 tables in the datagride with me condition that i have made in sql statement in reglz which is (where fatrname LIKE '%" & TextBox1.Text & "%' ") then i want to save another word instead of the current one in database and here my working code Dim x As String x = "'" & TextBox2.Text & "'" Call conn() cmd.CommandText = "update reglz set fatrname = " & x & " where fatrname LIKE '%" & TextBox1.Text & "%' " DataGridView1.Refresh() ad.SelectCommand = cmd ad.Fill(ds, "dd") DataGridView1.DataSource = ds.Tables("dd") but how can i apply this code to the 2 table SO what i want is :- how can i select 2 tables to show them in a datagrid how can i save any word for the two tables accroding to my condition . plz help me and thanks
Good morning MageDHV i hope following code will help you. if you want to update,Insert,Delete, you have to Add relations to this Code, but this one Will Display you 2table. i Suggest you do one thing at a time, try Displaying results from 2tables and then display results based
Dim strconnection As String = "workstation id=5875-049;packet size=4096;user id=sde;Password=topology;data source=SGIICORNETGS01;persist security info=False;initial catalog=Tshwane\_Valuations" Dim cn As SqlConnection = New SqlConnection(strconnection) cn.Open()
Dim cmdstr as String = "Select Property_Mass.boundary_Area, " _
" & Property_Mass.Actual_Extent, Property_Mass.Attrib_code, " _
" & Property_Mass.Lis_key, Property_Mass.Func_key, Property_Mass.Density, " _
" & Property_Mass.New_Net_Usable_Extent, Property_Mass.New_Total_Land_Factor, " _
" & Property_Mass.New_AdJ_Extent_1, Property_Mass.New_Points_1, Property_Mass.New_ADJ_Extent_2 , " _
" & Property_Mass.New_Points_2, Property_Mass.Fin_LS_Prediction, Property_Mass.Confidence_score , " _
" & Property_Mass.Flagtype, Property_Summary.Purchase_Date, Property_Summary.Purchase_Price " _
" & from Property_Mass, Property_Summary " _
" & where Property_Mass.Lis_key = Property_Summary.Lis_key "
Dim da As New SqlDataAdapter(cmdStr, cn)
Dim ds As New DataSet
da.Fill(ds)
Dim dv As New DataView(ds.Tables("Property_Mass"))
dgDetails.DataSource = dvit will look Buggy, but i want you to get th Logic, you create a Join and test it if its working and apply it in your string variable and display it on your table, tell me if you were able to do that, and we will go to the search based on textbox input. that would be easy you will see.
Vuyiswa Maseko