Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FlexGrid? DataGrid? Data Environment? ADODC? HEEEELLLLPPP!!!! 3

Status
Not open for further replies.

DariceLR

MIS
Jun 20, 2001
27
US
OK...
I am about ready to run through the hall screaming....

TWO QUESTIONS:


I need to have my VB6 app touch SQL7 databases, one that is used merely for searching for data to put in the other's tables. SO... One has a table that I need to read(empl), one has MANY tables that I need to read/write (used to track requests for work).

What kind of data connection is best??? Should I use a Data Environment? A ADODC? A regular Data Control? I am currently using both an ADO Data Control that has an ODBC Data Connection and an ADO Data Control that uses a connection string (Provider=MSDASQL.1;Persist Security Info=False;User ID= ;Data Source=(read only database);Mode=Read|Write;Initial Catalog=(read/write database))

So... The second problem??? It is not updating the files and the way that my data controls are set up, I get data immediately on the opening of the form, which what I want is it opening to capture data that will be entered by the user and then saved to the db when the save button is pressed. The read/write table/db should not be shown at all while the read only table/db is used to add users/customers information like their employee id. I am currently using a Hierarchical FlexGrid but want it to only show the rows that fit the criteria of a SQL statement that is generated with user input...

The user then selects that record and it's information will be passed to the form calling this "Search" form.

How do I utilize a SQL statement to populate a FlexGrid... Should I be using a different type of Grid object?

THANNNNKSSS. (I'll go scream in the hall and wait for your replies)



****************
DariceLR
:-{} :-V :-x
****************
 
First of all you can't use a Flex Grid to update records to a backend database - it's read only. I would use the DataGrid control instead. You can find that in the Project Components. Then you have to go into the properties of the DataGrid enable it to add, delete and edit records.

As for you Data Access Method, I am not fond of the Data Environment Designer nor the ADODC control. But it's all a matter of personal preference. What I do is create a connection object as a variable and then create my connection string. It requires more programming because you then have to program the data binding for each field to the recordset object. But in the end your database runs faster.

I also think that using the OLEDB Provider is faster than using ODBC. You'll be going through one less layer in accessing your database.

Here is an example of code I have written to create a connection and recordset. You don't have to follow it but it's just an idea.

Option Explicit
Dim objConn As ADODB.Connection
Dim objRec As ADODB.Recordset

Private Sub Form_Load()
Set objConn = New ADODB.Connection
objConn.ConnectionString = "Provider=SQLOLEDB.1;" & _
"Data Source=BSPSQLT; Initial Catalog = CQC_REVIEW; UID = OWENC; Password = cqcreview"
objConn.Open

If objConn.State = adStateOpen Then
MsgBox "Connection Successful!"
Else
MsgBox "Connection Unsuccessful - Try Again!"
End If

Set objRec = New ADODB.Recordset

objRec1.Open ("SELECT * FROM tblAccountInfo"), objConn, adOpenStatic, adLockBatchOptimistic

Set Text1.DataSource = objRec
Text1.DataField = "LoanScore"
(NOTE:YOU'LL HAVE TO DO THIS FOR EACH FIELD ON YOUR FORM TIED TO THAT RECORDSET)

objRec.MoveFirst
End Sub

 
I made a typo at the bottom of my response. Where it says objRec1, replace it with objRec.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top