necesito una mano con un sistema que tengo.
essta es mi base de datos:
--para esto me dieron esta solucion:
Cita:
Y ahora tengo este metodo que muestra en DataGrid una sentencia select.select t1.*, t2.apellido as chofer, t3.apellido as lider, t4.apellido as auxiliar from registroflota as t1
inner join personal as t2 on (t1.cod_chofer=t2.cod_personal)
inner join personal as t3 on (t1.cod_lider=t3.cod_personal)
inner join personal as t4 on (t1.cod_auxiliar1=t4.cod_personal)
inner join personal as t2 on (t1.cod_chofer=t2.cod_personal)
inner join personal as t3 on (t1.cod_lider=t3.cod_personal)
inner join personal as t4 on (t1.cod_auxiliar1=t4.cod_personal)
ese metodo quiero agregar mi sentencia select anterior
Código:
ahora, lo que necesito es que en la parte del Query de visalB pueda colocar la nueva sentencia, no se como elaboar el query, por que de la forma en que lo tengo no lo detectaPublic Sub CargaTabla() MysqlConn = New MySqlConnection MysqlConn.ConnectionString = "server = localhost; user id=root; password=transat; database = transat" Dim SDA As New MySqlDataAdapter Dim bSource As New BindingSource Try Dim query As String query = "SELECT * FROM registroflota" Command = New MySqlCommand(query, MysqlConn) 'codigo para llenar el data gridviw SDA.SelectCommand = Command SDA.Fill(dbDataset) bSource.DataSource = dbDataset DataGridViewRF.DataSource = bSource SDA.Update(dbDataset) Catch ex As MySqlException MessageBox.Show(ex.Message) Finally MysqlConn.Dispose() End Try End Sub
Código:
Try Dim query As String query = select t1.*, t2.apellido as chofer, t3.apellido as lider, t4.apellido as auxiliar from registroflota as t1 inner join personal as t2 on (t1.cod_chofer=t2.cod_personal) inner join personal as t3 on (t1.cod_lider=t3.cod_personal) inner join personal as t4 on (t1.cod_auxiliar1=t4.cod_personal) Command = New MySqlCommand(query, MysqlConn) 'codigo para llenar el data gridviw SDA.SelectCommand = Command SDA.Fill(dbDataset) bSource.DataSource = dbDataset DataGridViewRF.DataSource = bSource SDA.Update(dbDataset) Catch ex As MySqlException MessageBox.Show(ex.Message) Finally MysqlConn.Dispose()