A database is created in oracle %26amp; is connected with the Visual Basic project,we have to show the selected containts of 2 tables in Vb form.
How to use MSHFlexGrid in VisualBasic to show selected fields of 2 tables in oracle,Plz give Coding?
Here I have used MSHFlexgrid but I have connected to MS-Access
Just change the connection part, I think you can carry out the rest
Dim Mycon As New ADODB.Connection
Dim M1 As New ADODB.Recordset
Dim M2 As New ADODB.Recordset
Dim S1 As String
Private Sub Command1_Click()
Me.Refresh
Mycon.Open S1
M2.Open "select cust_details.customer_id,cust_details.cu... from cust_details,dress_details where cust_details.customer_id=dress_details.c... Mycon, adOpenDynamic, adLockOptimistic
Dim c As Integer
Dim r As Integer
Dim col_wid() As Single
Dim field_wid As Single
' Use one fixed row and no fixed columns.
MSHFlexGrid1.Rows = 2
MSHFlexGrid1.FixedRows = 1
MSHFlexGrid1.FixedCols = 0
' Display column headers.
MSHFlexGrid1.Rows = 1
MSHFlexGrid1.Cols = M2.Fields.Count
ReDim col_wid(0 To M2.Fields.Count - 1)
For c = 0 To M2.Fields.Count - 1
MSHFlexGrid1.TextMatrix(0, c) = M2.Fields(c).Name
col_wid(c) = TextWidth(M2.Fields(c).Name)
Next c
' Display the values for each row.
r = 1
Do While Not M2.EOF
MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1
For c = 0 To M2.Fields.Count - 1
MSHFlexGrid1.TextMatrix(r, c) = _
M2.Fields(c).Value
' See how big the value is.
field_wid = TextWidth(M2.Fields(c).Value)
If col_wid(c) %26lt; field_wid Then col_wid(c) = _
field_wid
Next c
M2.MoveNext
r = r + 1
Loop
' Close the recordset and connection.
' Set the column widths.
For c = 0 To MSHFlexGrid1.Cols - 1
MSHFlexGrid1.ColWidth(c) = col_wid(c) + 240
Next c
M2.Close
Mycon.Close
End Sub
Private Sub Form_Load()
S1 = "Provider=Microsoft.Jet.OLEDB.4.0;" %26amp; _
"Data Source=" %26amp; _
"c:\design.mdb"
End Sub
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment