❔ C# Need help with changing SQL connection string
I got a program which has database in it but I can't run it properly as I don't know how to change the SQL connection string. Please help me
16 Replies
Dispose your sql connection, and prob your adapter as well
<configuration>
<connectionStrings>
<add name="ETCDatabase" connectionString='Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="D:\Users\James\Downloads\ETCWinFormsApp\ETCDatabase.mdf";Integrated Security=True'
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
connection string I assume to be fine
Someone shared the program to me and do I have to change the SQL connection string accordingly to run the program?
Does the path to that file / the file exist?
Oh yea I have the file and the path to it
I was looking for it
@OneWholesomeDev
do i have to change the file path?
if the file path is the same as your config, then no
ok i have just fixed the database file path
now it shows another problem
Now your connection string is borked
I changed my sql connection string from this
To this:
<configuration>
<connectionStrings>
<add name="ETCDatabase" connectionString='Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename="D:\IOOP\ETCWinFormsApp_20230219\ETCWinFormsApp\ETCDatabase.mdf"Integrated Security=True'
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
===================
"D:\IOOP\ETCWinFormsApp_20230219\ETCWinFormsApp\ETCDatabase.mdf"
this is the path to the file i copied from file explorer
Youre missing a semicolon
ohh god
hang on
@OneWholesomeDev Thanks lots
😭😭🙏🏻🙏🏻
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.