data environment location

deepakaa
01-13-2004, 10:16 AM
in my application i m using a data environment....at the design time i connected it with database manually like....C:\Documents and Settings\abc\.....but know i m making setup file so i have to change this adress using app.path so pls tell me how to do it...i tried

app.path & "\order.mdb"

but it didnt work...

pls tell the solution

thanx.

deepakaa
01-13-2004, 10:35 AM
:confused: am i clear enough with the problem..if so, pls someone suggest the solution

deepakaa
01-13-2004, 11:03 AM
:confused: :eek: :mad: .......friends i m waiting 4 the rply as i dont get any idea that to move

thanx.

Shurik12
01-13-2004, 11:20 AM
Hi,
In the connection string to the database you'd have:

"DataSource=" & AppPath & "\order.mdb;....."


Regards,
Shurik.

deepakaa
01-14-2004, 04:03 AM
thanx shurik for the rply..

but its still not working...i think i m doing mistake somewhere in defining data sourche...

so i m writing u the steps i follow..

* opened dataenvironment
* right clicked on connection 1 and selected properties..
* in provider i selected Microsoft Jet 3.51 OLE DB Provider clicked on 'next'
* in connection tab i entered the database name as
"Data Source=" & app.path & "\envoi_recevoi.mdb;"
* clicked on test connection and got an error which reads
test connection failed because of an error in intialising provider. file name is incorrect.

pls tell me where m i going wrong...and suggest the solution

thanx.

Dennis DVR
01-14-2004, 04:05 AM
the data environment has an initialize event put your code there.


Private Sub DataEnvironment_Initialize()
dConnection.cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CET.mdb;Persist Security Info=False"
End Sub

deepakaa
01-14-2004, 04:18 AM
i wrote following lines in dataenvironment initialize event but still not working...i got the error this operation is not allowed when the obeject is closed

Private Sub DataEnvironment_Initialize()
Connection1.cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\envoi_recevoi.mdb;Persist Security Info=False"

End Sub

Dennis DVR
01-14-2004, 04:48 AM
are you sure connection1 is the name of your dataenvironment?


or try this one
declare a global variable for your string connection and and put the code on your form load event

Private Sub Form_Load()
cnnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\CET.mdb;Persist Security Info=False"
End Sub

'and this is how you to open your connection
Private Sub OpenIt()
If dConnection.cnn.State = adStateClosed Then
dConnection.cnn.Open cnnStr
End If
End Sub

deepakaa
01-14-2004, 05:04 AM
i m very very sorry to say but still i m getting the same error that this operation is not allowed when the object is closed

connection1 is the name of connection
dataenvironment name is 'dataenvironment_envoi'....so i put following line on the dataenvironment code page i wrote following lines

Private Sub DataEnvironment_Initialize()

DataEnvironment1_envoi.Connection1.cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\" & "envoi_recevoi.mdb" & ";Persist Security Info=False"

End Sub

but i got above error...

and what is

Private Sub OpenIt()
If dConnection.cnn.State = adStateClosed Then
dConnection.cnn.Open cnnStr
End If
End Sub

where should i put this lines...am i supposed to put these line on form code page..and could u pls explain little bit what adstateClosed mean...

very very sorry to bother u again and again...
thanx.

Dennis DVR
01-14-2004, 05:11 AM
I just made a sub what I mean there is that thats ther you should open your data environment.

Dennis DVR
01-14-2004, 05:13 AM
remove the connection1
DataEnvironment1.Cnn.ConnectionString = "blah.,,,"

deepakaa
01-14-2004, 05:46 AM
ok i got the whole situation and i these lines on the form code page so if user will click on the command button 'report' following lines will be exectued...and i removed everything from the dataenvironment code page...and from the connectionsource property of the connection1

but i got an error "supplied provider is different from the one already in use"

Load DataEnvironment1_envoi

cnnstr = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & "\envoi_recevoi.mdb;Persist Security Info=False"

If DataEnvironment1_envoi.Connection1.State = adStateClosed Then
DataEnvironment1_envoi.Connection1.Open cnnstr '......error here
end if

pls tell me what is this error and how to remove it...

thanx.

Dennis DVR
01-14-2004, 05:58 AM
did you read my last post you only need to remove the connection1 on your connection string.


well it happens when you change your provider at runtime and your data report was binded at designtime the data report uses the msdatashape
so before calling the datareport you should change the privider in its default value i.e in your form load event but make it sure the oldCnn was declared global under you module.


oldCnn = "Provider=MSDataShape.1;Persist Security Info=False;Data Source=" & App.Path & "\CET.mdb;Data Provider=MICROSOFT.JET.OLEDB.4.0"


change the database name of your database
now here what you should do before calling the data report

'reset to the default provider
dConnection.cnn.Open oldCnn

deepakaa
01-14-2004, 06:09 AM
anyhow duane i got it...its working just fine now....thanx alot for the support...

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum