C
C#2y ago
hehe xd

❔ C Sharp Windows Form executable with local database

Hello guys, I've made a project in C# Windows Forms that uses local database (Azure). Since it's local that means that program will only work on my computer. However, my lecturer wants to have this program working on his computer. How would I do that? Right now, my connection is hardcoded to my computer
SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\david\Documents\AFDb.mdf;Integrated Security=True;Connect Timeout=30");
SqlConnection Con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\david\Documents\AFDb.mdf;Integrated Security=True;Connect Timeout=30");
12 Replies
MasterSubarashii
you may download the database file and hand it over ah i read it wrong if this is going to be a face-to-face lesson, you can just keep your SQL up and the internet connection on so the teacher can connect and probably you can register it to Azure? but yeah if you are on the same local network via cable, you can connect
hehe xd
hehe xdOP2y ago
@MasterSubarashii No, it's not face-to-face. I have it on my computer but he wants to have the program himself and use it without my interference.
MasterSubarashii
does he think that you guys own a server? 🤨
MasterSubarashii
you guys might try this
hehe xd
hehe xdOP2y ago
So I pretty much need to buy server in order to send him working project?
MasterSubarashii
you can just tell him to change the connection string to his computer name and add the database file to his SQL well, you can't keep your computer open all the time and even if it's open you need his ports to log on
hehe xd
hehe xdOP2y ago
How would he access connection string if he doesn't have visual studio to access the code?
MasterSubarashii
ohh he wants it as an .EXE file aight i have no idea then, sorry
hehe xd
hehe xdOP2y ago
I used ChatGPT and it did mention something about creating config file which would include my connection string but I'm not sure how to connect that with my stuff and would I need to send him like my Release folder?
MasterSubarashii
yeah you can do that
<connectionStrings>
<add name="TableName" connectionString="your connection string"/>
</connectionStrings>
<connectionStrings>
<add name="TableName" connectionString="your connection string"/>
</connectionStrings>
and it's still a problem to connect to your SQL Database there is a app.config file inside where your form is placed
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