0 pts.
 about flexrgrid control
Sir, I would like to know that how we can use flexgrid control for inserting the data through flexgrid into database file. please send me the tips or send me the source code to handle this. thanks arshad

Software/Hardware used:
ASKED: June 22, 2005  8:14 AM
UPDATED: June 30, 2005  4:24 PM

Answer Wiki:
What kind of flexgrid do you use. What environment: development language, tools, OS, etc.?
Last Wiki Answer Submitted:  June 22, 2005  2:38 pm  by  Harinck   0 pts.
All Answer Wiki Contributors:  Harinck   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

This code sample shows you how to load data from a database into a Flexgrid. It is the same concept to obtain the data from Flexgrid and put it into a database.

******************************************************

Private Sub Form_Load()

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim dbase As String
Dim sSQL As String
Dim iCount As Integer
Dim iField As Integer
Dim columnwidth() As Single
Dim fieldwidth As Single

‘ Get the data.
dbase = “c:somedatabase.mdb”

‘ Open a connection.
Set cn = New ADODB.Connection
cn.ConnectionString = _
“Provider=Microsoft.Jet.OLEDB.4.0;” & _
“Data Source=” & dbase & “;” & _
“Persist Security Info=False”
cn.Open

‘ Select the data.
sSQL = “SELECT * FROM SOMETABLE”

‘ Create Recordset
Set rs = cn.Execute(sSQL)

‘ Define MSFlexGrid
‘ Use one fixed row and no fixed columns.
MSFlexGrid1.Rows = 2
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FixedCols = 0

‘ Display column headers.
MSFlexGrid1.Rows = 1
MSFlexGrid1.Cols = rs.Fields.Count
ReDim columnwidth(0 To rs.Fields.Count – 1)
For iCount = 0 To rs.Fields.Count – 1
MSFlexGrid1.TextMatrix(0, iCount) = rs.Fields(iCount).Name
columnwidth(iCount) = TextWidth(rs.Fields(iCount).Name)
Next

‘ Display the values for each row.
iField = 1
Do While Not rs.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For iCount = 0 To rs.Fields.Count – 1
MSFlexGrid1.TextMatrix(iField, iCount) = _
rs.Fields(iCount).Value

‘ See how big the value is.
fieldwidth = TextWidth(rs.Fields(iCount).Value)
If columnwidth(iCount)

 0 pts.

 

This code sample shows you how to load data from a database into a Flexgrid. It is the same concept to obtain the data from Flexgrid and put it into a database.

******************************************************

Private Sub Form_Load()

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim dbase As String
Dim sSQL As String
Dim iCount As Integer
Dim iField As Integer
Dim columnwidth() As Single
Dim fieldwidth As Single

‘ Get the data.
dbase = “c:somedatabase.mdb”

‘ Open a connection.
Set cn = New ADODB.Connection
cn.ConnectionString = _
“Provider=Microsoft.Jet.OLEDB.4.0;” & _
“Data Source=” & dbase & “;” & _
“Persist Security Info=False”
cn.Open

‘ Select the data.
sSQL = “SELECT * FROM SOMETABLE”

‘ Create Recordset
Set rs = cn.Execute(sSQL)

‘ Define MSFlexGrid
‘ Use one fixed row and no fixed columns.
MSFlexGrid1.Rows = 2
MSFlexGrid1.FixedRows = 1
MSFlexGrid1.FixedCols = 0

‘ Display column headers.
MSFlexGrid1.Rows = 1
MSFlexGrid1.Cols = rs.Fields.Count
ReDim columnwidth(0 To rs.Fields.Count – 1)
For iCount = 0 To rs.Fields.Count – 1
MSFlexGrid1.TextMatrix(0, iCount) = rs.Fields(iCount).Name
columnwidth(iCount) = TextWidth(rs.Fields(iCount).Name)
Next

‘ Display the values for each row.
iField = 1
Do While Not rs.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
For iCount = 0 To rs.Fields.Count – 1
MSFlexGrid1.TextMatrix(iField, iCount) = _
rs.Fields(iCount).Value

‘ See how big the value is.
fieldwidth = TextWidth(rs.Fields(iCount).Value)
If columnwidth(iCount)

 0 pts.

 

I don’t use them, but Microsoft has a data bound grid control.

 0 pts.