Connection/data source from local SQL Server

Stimulsoft Reports.Flex discussion
Locked
ssteketee
Posts: 10
Joined: Mon Jan 14, 2019 1:01 am

Connection/data source from local SQL Server

Post by ssteketee »

I am a novice in working with Stimulsoft and SQL but so far so good, have made some great reports so far.

Am trying to add a second data source to a report and this second data source is located on my local workstation currently. I have the data in several different formats just trying to get something to work -- it is originally a dBase file, have it as a SQL mdf, Access mdb file, an Excel file, xml. But no matter what connection type and string I try I cannot get connected to this local data.

Should I be able to add this local data source? And which connection type and string would be best?

Thank you, all!
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Connection/data source from local SQL Server

Post by Lech Kulikowski »

Hello,

For different formats, you should use different connections - SQL, MS Access, XML etc

Thank you.
MarleneGaima
Posts: 1
Joined: Mon Aug 26, 2019 8:07 pm
Location: Egypt

Connection/data source from local SQL Server

Post by MarleneGaima »

I have a preexisting crystal report and I used an editor to pull out the SQL code. I cannot simply use that code in Microsoft SQL Server Management Studio 17 without modifying it. unfortunately, the code is more complicated than what I am used to working with and I would like some assistance.

Code from crystal report:
Code:
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: Connection/data source from local SQL Server

Post by Andrew »

Hello,

What code are you using?

Thank you.
Kiyaksar
Posts: 6
Joined: Sat May 01, 2021 5:53 pm

SQL Connection String

Post by Kiyaksar »

Hi everyone...
I have made my WPF project reports by stimulsoft reports with this SQL server connection string (Data Source=.;Initial Catalog=DBNBO;Integrated Security=True;),
I want to make a setup file for my project by Advanced Installer program for this purpose I have transferred my database to SQLExpress and I have moved mdf and ldf file to my debug project file. I need to change reports sql connection string in stimulsoft reports so that it can execute correctly; but I don't know how to do this.
Can anybody help me, please?
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Connection/data source from local SQL Server

Post by Lech Kulikowski »

Hello,

You can use the following code:
((StiSqlDatabase)report.Dictionary.Databases[ "ConnectionName"]).ConnectionString = "";

Thank you.
Kiyaksar
Posts: 6
Joined: Sat May 01, 2021 5:53 pm

Re: Connection/data source from local SQL Server

Post by Kiyaksar »

Thanks for your answer
As you see below the first one is the connection string I used in WPF c#, and the other one I used in stimulsoft. it works correctly; but when I transfer my database from SQL server to SQL express and I move MDF and LDF files to debug folder of the project to create a setup file for it by advanced installer it doesn't work and it shows this error (Cannot open database "DBNBO" requested by the login. The login failed.Login failed for user 'NAWZAD\Nawzad'); I think I have to change (Data Source=.; ) to (Data Source=.\SQLExpress;); but what can I do for (Initial Catalog=DBNBO;)?

1- rptSentReport.Dictionary.Databases.Add(new StiSqlDatabase ("PublicSent", "Data Source=.;Initial Catalog=DBNBO;Integrated Security=True;"));
2- Data Source=.;Initial Catalog=DBNBO;Integrated Security=True;
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

Re: Connection/data source from local SQL Server

Post by Lech Kulikowski »

Hello,

You should use correct connection string:
Please check
Server=.\SQLExpress;AttachDbFilename=C:\MyFolder\MyDataFile.mdf;Database=dbname;Trusted_Connection=Yes;
https://www.connectionstrings.com/sql-server/

Thank you.
Locked