I have 1 datagrid which source comes from 1 table. It is working. But I need to combine the table with other 2 tables as the main table only shows the key of the other 2. I need to get the description of the keys from the 2 tables. I know the sql command,and it uses dataview but I'm not sure how to implement it into datagrid. Below is the coding i use to get the data from 1 table to the datagrid.I use VStudio 2003. I'm a beginner, therefore if someone could explain and show me the url that shows the coding to combined few tables into the datagrid, I will appreciate it very much.
Private Sub LoadGrid()
Dim data As DataTable = OgManager.GetData(" status <> " & eStatus.Deleted & " AND SerialNo like '%" & txtSearchbySerialNo.Text & "%'")
grdData.DataSource = data
Dim dsn As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
End Sub
Public Shared Function GetData(ByVal criteria As String) As DataTable
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("DSN")
Dim query As String = "select * from SerialNo"
If criteria <> "" Then
query = query & " where " & criteria
End If
Dim Dt As DataTable = DataManager.ExecuteQuery(ConnectionString, query, "SerialNo")
Return Dt
End Function
Public Shared Function ExecuteQuery(ByVal ConnectionString As String, ByVal query As String, Optional ByVal tableName As String = "Table1") As DataTable
Try
Dim myConnection As OleDbConnection = New OleDbConnection(ConnectionString)
Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(query, myConnection)
Dim ds As DataSet = New DataSet
myAdapter.Fill(ds, tableName)
ds.Tables(0).TableName = tableName
Return ds.Tables(0)
Catch ex As Exception
Try
Utils.LogError(ex, "Error in ExecuteQuery() method in DataManager. <BR><BR>" & query)
Catch
End Try
Throw
End Try
End Function
Private Sub LoadGrid()
Dim data As DataTable = OgManager.GetData(" status <> " & eStatus.Deleted & " AND SerialNo like '%" & txtSearchbySerialNo.Text & "%'")
grdData.DataSource = data
Dim dsn As String = System.Configuration.ConfigurationSettings.AppSettings("dsn")
End Sub
Public Shared Function GetData(ByVal criteria As String) As DataTable
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("DSN")
Dim query As String = "select * from SerialNo"
If criteria <> "" Then
query = query & " where " & criteria
End If
Dim Dt As DataTable = DataManager.ExecuteQuery(ConnectionString, query, "SerialNo")
Return Dt
End Function
Public Shared Function ExecuteQuery(ByVal ConnectionString As String, ByVal query As String, Optional ByVal tableName As String = "Table1") As DataTable
Try
Dim myConnection As OleDbConnection = New OleDbConnection(ConnectionString)
Dim myAdapter As OleDbDataAdapter = New OleDbDataAdapter(query, myConnection)
Dim ds As DataSet = New DataSet
myAdapter.Fill(ds, tableName)
ds.Tables(0).TableName = tableName
Return ds.Tables(0)
Catch ex As Exception
Try
Utils.LogError(ex, "Error in ExecuteQuery() method in DataManager. <BR><BR>" & query)
Catch
End Try
Throw
End Try
End Function