13 Answers, 1 is accepted
There is no problem to load the connection string from the web.config file. You can use the following pattern:
web.config:
<connectionStrings>
<add name="SampleDB" connectionString="Server=(local)\SQLEXPRESS;Integrated Security=true;Database=AdventureWorks" />
</connectionStrings>
report.vb:
Public Sub New()
InitializeComponent()
If ConfigurationManager.ConnectionStrings("SampleDB") IsNot Nothing Then
Me.conn.ConnectionString = ConfigurationManager.ConnectionStrings("SampleDB").ConnectionString
End If
End Sub
where Me.conn is the SqlConnection object.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

- will

Hi,
I use that metod, but visual studio indicates
" 'cnn' is not a member of 'Report1'
I need to Import any namespace?
Public Sub New()
InitializeComponent()
If ConfigurationManager.ConnectionStrings("cnConnection") IsNot Nothing Then
Me.conn.ConnectionString = ConfigurationManager.ConnectionStrings("cnConnection").ConnectionString
End If
End Sub
You have to either define the conn as local variable or set the datasource of the report in order to have it as member of Report1. I've attached a sample app showing one of the approaches.
All the best,
Steve
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

After I download parameterconnectstring.zip , i can not view content because I am using VS 2005 and use C# , can you please post how this solution works? ( need sample syntax for connection string from web.config)
thanks!!
We've created a code library elaborating on this and containing C# code sample. For future reference, please note that you can always use our or any other code converter on the net to convert code.
Sincerely yours,
Steve
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

you don't have the exemple to VS2005 ??
The Visual Studio version is not relevant in this case, but in fact the attached project is for VS2005. Please review the explanation and code provided to understand how it works.
Kind regards,
Steve
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

InitializeComponent();
// add below 2 line for use connection from web.config
this.myDataSetTableAdapter1.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
this.myDataSetTableAdapter1.Fill(this.myDataSet.myDataSetTable);
After add above last 2 line for try to use connection string from web.config ,
when i click preview or HTML preview , then this simple report will display
no any data except heading. (it was good if i remove last 2 line)
Can you please advice and help? I already read menu & samples again and again
but did not solve this 'using web.config for connection' for my simple report.
Have you tried debugging, so that you could see that the ConnectionString is properly overridden and that you have data in your DataSet? Please try isolating the issue as much as possible and provide more info, as "not working" does not help us much in identifying the problem.
Greetings,
Steve
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Just in case someone else need this solutions as below:
...
using
System.Configuration;
using System.Data.SqlClient;
...
try
{
ConnectionStringSettings
connSettings = ConfigurationManager.ConnectionStrings["myConnectionString"];
if ((connSettings != null) && (connSettings.ConnectionString != null))
{
this.ds1TableAdapter1.Connection.ConnectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
}
this.ds1TableAdapter1.Fill(this.ds1.dsWip1Table);
(above line may different wheich already exist before add from web.config)
*** really appreciate tech support's help

I, can solve to.
to VB
need to reference the System.Configuration on referecies
Imports
System.Data.SqlClient
Imports System.Configuration
Public Sub New()
InitializeComponent()
Dim
sqlconnection1 As New SqlConnection()
Dim sqlCOmmand1 As New SqlCommand
Dim sqldataadaptater As New SqlDataAdapter
sqlconnection1.ConnectionString = ConfigurationManager.ConnectionStrings(0).ConnectionString
sqlconnection1.ConnectionString = ConfigurationManager.ConnectionStrings(
"ConnectiosONWebINI").ConnectionString
sqlCOmmand1.CommandText =
"SELECT * from companys"
sqlCOmmand1.Connection = sqlconnection1
sqldataadaptater.SelectCommand = sqlCOmmand1
Me.DataSource = sqldataadaptater
End Sub

I add report parameter which use Data source for a dropdown list
by select single value of 'state' (key value), Now the problem come
again, 'How can i use web.config for SQL connection string ?'
Just like my last post that this report can use web.config for SQL connection
for adding line '
ConnectionStringSettings
connSettings = ConfigurationManager.ConnectionStrings["myConnectionString"];
...
Please advice that how to implement this web.config into report parameter section
which is UI --- available value (a datasource).