C
C#2y ago
gabrielji

❔ 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
Monsieur Wholesome
Dispose your sql connection, and prob your adapter as well
gabrielji
gabrieljiOP2y ago
<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>
Monsieur Wholesome
connection string I assume to be fine
gabrielji
gabrieljiOP2y ago
Someone shared the program to me and do I have to change the SQL connection string accordingly to run the program?
Monsieur Wholesome
Does the path to that file / the file exist?
gabrielji
gabrieljiOP2y ago
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?
Monsieur Wholesome
if the file path is the same as your config, then no
gabrielji
gabrieljiOP2y ago
ok i have just fixed the database file path now it shows another problem
gabrielji
gabrieljiOP2y ago
Monsieur Wholesome
Now your connection string is borked
gabrielji
gabrieljiOP2y ago
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
Monsieur Wholesome
Youre missing a semicolon
gabrielji
gabrieljiOP2y ago
ohh god hang on @OneWholesomeDev Thanks lots
gabrielji
gabrieljiOP2y ago
😭😭🙏🏻🙏🏻
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server