Setting ADODC control's datasource at runtime

Setting ADODC control's datasource at runtime

Post by Bill Henrie » Sat, 20 Jul 2002 16:44:24



Hello all,
I'm trying to set an ADO data control's recordsource at runtime, but when
the form loads, I get the error for each data control on the form:

[ADODC]:  no RecordSource specified. [ADO]: Command Text was not set for the
command object.

I do NOT want to set the recordsource property at design time.  What can I
do to avoid the error when the form loads?  This error happens when I load
the form in the IDE in design mode as well.  The recordsource was never
required at design time with DAO data controls.  What am I missing?  Thanks,

Bill

 
 
 

Setting ADODC control's datasource at runtime

Post by bmacarthu » Sat, 20 Jul 2002 16:22:12


I don't have answer for this, unfortunately. I came on here with the same
problem.

Everything I've read makes it sound very simple and says to set the
connection string at design time, and then change the connection string with
the Form_Load event. I have tried this and it doesn't work. When the form
loads, it still tries to connect to the hard-coded connection string. If the
file is not in that location, I get errors, and the commands in the
Form_Load event never occur. How do I set the connection string at run-time
so that I can use the app.path.

Below is the code I am trying in the Form_Load event (I have also tried it
in Form_Initialize):

Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
App.Path & "\Funds.mdb;Persist Security Info=False"

-Brent


Quote:> Hello all,
> I'm trying to set an ADO data control's recordsource at runtime, but when
> the form loads, I get the error for each data control on the form:

> [ADODC]:  no RecordSource specified. [ADO]: Command Text was not set for
the
> command object.

> I do NOT want to set the recordsource property at design time.  What can I
> do to avoid the error when the form loads?  This error happens when I load
> the form in the IDE in design mode as well.  The recordsource was never
> required at design time with DAO data controls.  What am I missing?
Thanks,

> Bill


 
 
 

Setting ADODC control's datasource at runtime

Post by Rames » Sat, 20 Jul 2002 23:35:42


Hello Bill and Brent,
You are seeing this error messsage because you set part of the ADO
Datacontrol's properties at design time and some of it at runtime.
This error was caused by the setting the ADODC Connectionstring property in
design time, but not its Recordsource property.    My suggestion will be to
set all the pertinent data control properties in runtime, i.e. the
Connectionstring, Recordsource, and Commandtype.  Once assigning
appropriate
values to these properties in code, the next step will be to execute the
ADODC Refresh method.

Hope this helps!

Ramesh Thyagarajan, MCSD,MCDBA
Microsoft Developer support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

 
 
 

Setting ADODC control's datasource at runtime

Post by bmacarthu » Sun, 21 Jul 2002 13:57:27


Ramesh, that did the trick!

Thank you very much!!

-Brent


Quote:> Hello Bill and Brent,
> You are seeing this error messsage because you set part of the ADO
> Datacontrol's properties at design time and some of it at runtime.
> This error was caused by the setting the ADODC Connectionstring property
in
> design time, but not its Recordsource property.    My suggestion will be
to
> set all the pertinent data control properties in runtime, i.e. the
> Connectionstring, Recordsource, and Commandtype.  Once assigning
> appropriate
> values to these properties in code, the next step will be to execute the
> ADODC Refresh method.

> Hope this helps!

> Ramesh Thyagarajan, MCSD,MCDBA
> Microsoft Developer support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

 
 
 

Setting ADODC control's datasource at runtime

Post by Han » Sun, 21 Jul 2002 16:57:56


Ramesh

Do you or anyone know an issue of doing without adodc? I'm using datagrid
connected to db without adodc. I'm curious and worrying whether there is a
problem in my behavior.

rst.CursorLocation = 3
rst.Open "SQL",CON,1,3,1
Set datagrid1.DataSource = rst

--
Han Pohwan, Seoul/Korea


Quote:> Hello Bill and Brent,
> You are seeing this error messsage because you set part of the ADO
> Datacontrol's properties at design time and some of it at runtime.
> This error was caused by the setting the ADODC Connectionstring property
in
> design time, but not its Recordsource property.    My suggestion will be
to
> set all the pertinent data control properties in runtime, i.e. the
> Connectionstring, Recordsource, and Commandtype.  Once assigning
> appropriate
> values to these properties in code, the next step will be to execute the
> ADODC Refresh method.

> Hope this helps!

> Ramesh Thyagarajan, MCSD,MCDBA
> Microsoft Developer support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

 
 
 

Setting ADODC control's datasource at runtime

Post by Matt » Sun, 21 Jul 2002 19:40:04


Thats great! I had this problem a while back and I'm now making another
database program, this helps a lot!
Thank you! :)

Matt


Quote:> Hello Bill and Brent,
> You are seeing this error messsage because you set part of the ADO
> Datacontrol's properties at design time and some of it at runtime.
> This error was caused by the setting the ADODC Connectionstring property
in
> design time, but not its Recordsource property.    My suggestion will be
to
> set all the pertinent data control properties in runtime, i.e. the
> Connectionstring, Recordsource, and Commandtype.  Once assigning
> appropriate
> values to these properties in code, the next step will be to execute the
> ADODC Refresh method.

> Hope this helps!

> Ramesh Thyagarajan, MCSD,MCDBA
> Microsoft Developer support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

 
 
 

Setting ADODC control's datasource at runtime

Post by Rames » Tue, 23 Jul 2002 22:15:24


Hello Han,
I have not encountered anything specific with not using ADODC.
ADODC is easy for simple applications. But doing everything thru code, you
have more control over the code.
I prefer doing it through code so that I dont have to rely on settings I
make at design time.

Hope this helps.!

Ramesh Thyagarajan, MCSD,MCDBA
Microsoft Developer support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

 
 
 

Setting ADODC control's datasource at runtime

Post by Han » Wed, 24 Jul 2002 08:10:35


Thanks Ramesh.

--
Han Pohwan, Seoul/Korea


Quote:> Hello Han,
> I have not encountered anything specific with not using ADODC.
> ADODC is easy for simple applications. But doing everything thru code, you
> have more control over the code.
> I prefer doing it through code so that I dont have to rely on settings I
> make at design time.

> Hope this helps.!

> Ramesh Thyagarajan, MCSD,MCDBA
> Microsoft Developer support

> This posting is provided "AS IS" with no warranties, and confers no
rights.

> Are you secure? For information about the Microsoft Strategic Technology
> Protection Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.

 
 
 

1. Need Help: Setting ADODC control ConnectString at Runtime

I *DO* know how to set a connection property in the property window and I
*DO* know how to create a ADO connection programatically, but in this
instance I must use an ADODC Active X data control and need to set the
connection to it programatically at the time the form is opened. There are a
boatload of databound text boxes, a datagrid, some checkboxes etc. that must
be bound to this control.

Let us assume I do not know the database name until runtime and can't path
it into the property view at design time:

I have tried the code below but get the "Adodc1: [Microsoft][ODBC Driver
Manager] data source name not found and no default driver specified." error
of death.
----------

Private Sub Form_Load()

Dim dbname as string
dbname=frmMain.label1.caption  '(example: "C:\My Documents\Mydbfile.mdb")

   With Adodc1
      .ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=" & dbname
      .RecordSource = "Select * From Table1"
   End With

End Sub

Any help would be greatly appreciated. I've obviously made a mistake
somewhere.

2. Need help with constraints

3. Setting Grid's DataSource at runtime

4. Query Analyzer debugging not working

5. ADODC control - DataSource Property back to nothing

6. Relational databases

7. txtfield().datasource property, without Adodc control

8. Converting access to paradox HELP

9. set datagrid.datasource = Adodc PROBLEM!

10. Finding 'DataSource' property at runtime

11. Adding a connection string to an ADODC control at runtime

12. Setting properties for ADODC during runtime...