No video

C# Tutorial - Change ConnectionString at Runtime with App.config | FoxLearn

  Рет қаралды 116,816

Fox Learn

Fox Learn

Күн бұрын

How to change connectionstring dynamically in c# connect to sql server database example. The c# basics beginner course is a free c# tutorial series that helps beginning programmers learn the basics of the c# programming language
Website: foxlearn.com
Through this video you will learn the following topics:
How to connect sql server database in c# windows application.
Next, create a database connection in c# with sql server, then change connection string dynamically c# entity framework. How to use c# configurationmanager set connection string with entity framework change connection string at runtime.
Learn sql server connection string example, then use c# configurationmanager to get connection string c#, through the example you can learn how to get connection string from sql server.
Learn how to connect sql database in c# and how to change connection string in app.config dynamically in c#
Next, change initial catalog in connection string c# and change data source connection string c#.
How to use connection string in app.config c# windows application to change connection string at runtime c#.
The best way to read the app.config connection string c#, then change the connection string dynamically for sqldatasource during run time.
Get and set c# application settings in runtime and learn how to read connectionstring from app config file in Visual Studio. Using the app.config in c# for creating global connectionstring and how to connect database in c#.

Пікірлер: 115
@sistemasaprovados
@sistemasaprovados 3 жыл бұрын
Muito Obrigado, você me fez dar um salto alto em meu projeto, nem sei como te agradecer, faltava somente isso para automatizar as configurações de conexão do meu sistema. Thank you very much, you made me take a high leap in my project, I don't even know how to thank you, that was all I needed to automate my system's connection settings.
@Microjam
@Microjam 3 жыл бұрын
Excellent presentation with a solution that works well. Easy to follow. Thank you.
@rafaelferreira7408
@rafaelferreira7408 3 жыл бұрын
Thank you, now I'm gonna try to do this with my WPF app.
@deepakbhanushali1
@deepakbhanushali1 4 жыл бұрын
Can you provide same thing for Access Database , I have 2 set of database 1st one is companymaster, 2nd is datamaster where datamaster will select database as per company name and financial year selected from companymaster
@abdulmalik1389
@abdulmalik1389 6 жыл бұрын
Excellent man, I love this video....this is something I was looking for...Thanks man
@hasmukhsavaliya4657
@hasmukhsavaliya4657 5 жыл бұрын
Hello, the XML configuration file (.exe.Config) file under bin > Debug folder is changed with new connection parameter using your solution, but there is no effect of changed connection string the program always using the old connection string when running again, Please help/correct ;)
@carlvergara7457
@carlvergara7457 6 жыл бұрын
Hi it says The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. I already check my app.config but stll i get that error, Thanks for the response. Please give me response because I badly need it.
@ybscambo6975
@ybscambo6975 3 күн бұрын
I want to know how to config firewall to use public ip connection
@AngelPatxiRodriguezFernandez
@AngelPatxiRodriguezFernandez 3 жыл бұрын
It works correctly in debug but when installing it in Program Files it does not work. It does not change the connection string. There is no permission to edit the file. Any suggestion?
@JuanRamirez-uq1ct
@JuanRamirez-uq1ct 4 жыл бұрын
Thanks for share this video. that was really helpful and I really enjoyed your explanation
@nboooly
@nboooly 4 жыл бұрын
thank you very much, that was very helpfull, ans the explaination is wonderful!
@SiakNiTonying
@SiakNiTonying 7 жыл бұрын
helllo foxlearn can i request ..how can you retrieve a data in database inserted to combo box or textbox or datagridview using this? thanks
@rockyivic
@rockyivic 3 жыл бұрын
Great video!!! Thanks!
@TanNguyen-wd1sp
@TanNguyen-wd1sp 3 жыл бұрын
Thank so much
@foxlearn
@foxlearn 3 жыл бұрын
You're welcome. Thank you !
@WillGab
@WillGab 6 жыл бұрын
How very clear tutorial, thank you so much.
@foxlearn
@foxlearn 6 жыл бұрын
Thank you so much !
@dailyquran2072
@dailyquran2072 3 жыл бұрын
Great Video
@theg4meover988
@theg4meover988 3 жыл бұрын
If i use entity framework in my c# project , should i go with the same process as the video ?
@marcusshamase2050
@marcusshamase2050 7 жыл бұрын
Hi thanks for the video. If I may ask is there a way to use two databases in one connectionstring c# winforms? Please help
@jaime2911
@jaime2911 6 жыл бұрын
You forgot to add in the video the reference to the System.Configuration class
@lps3026
@lps3026 7 жыл бұрын
Hi thanks so much for your video, but I want to ask how should I do if I use LinQ
@CarlosRivera-xu1zf
@CarlosRivera-xu1zf 2 жыл бұрын
Nice video
@fawazaliaskar
@fawazaliaskar 3 жыл бұрын
hi what if i use intity frame work what change need in connection string
@khanalzai20
@khanalzai20 7 жыл бұрын
i am getting this 2 errors Could not find schema information for the element connectionString the type initializer for system.data.sqlconnection threw an exception
@foxlearn
@foxlearn 7 жыл бұрын
Hi, Please check your connection string again in the app.config file. remember add reference to System.Configuration.dll. Thank you
@md.rezaulkarim
@md.rezaulkarim 6 жыл бұрын
Keyword not supported: 'datasource' Showing this error msg when I click connect button.
@elhoucineawixor3072
@elhoucineawixor3072 5 жыл бұрын
its " Data Source={0} " not " DataSource={0} "
@matigarimanjirungi59
@matigarimanjirungi59 6 жыл бұрын
Hello Foxlearn Facing an error @config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); Error number CS0029 : Cannot implicitly convert type 'system.configuration.configuration' to "***** .configuration please help
@hadirotafoua5381
@hadirotafoua5381 3 жыл бұрын
thanks
@foxlearn
@foxlearn 3 жыл бұрын
You're welcome!
@bongemhoangtu2468
@bongemhoangtu2468 6 жыл бұрын
Hello Fox, I have the error here how I can fix that? : 'The SelectCommand property has not been initialized before calling 'Fill'.'
@islam_TVs
@islam_TVs 4 жыл бұрын
Can you make a tutorial on How to make Setup File of a C# Windows Application with SQL server database. Database created on SSMS and connected through connection string.
@foxlearn
@foxlearn 4 жыл бұрын
ok. Thank you for your suggestion
@thong.na2510
@thong.na2510 7 жыл бұрын
Thank you!
@dailyquran2072
@dailyquran2072 3 жыл бұрын
I Want to know that how to implement this configuration page in our project? please...
@afzalhossainbd
@afzalhossainbd 4 жыл бұрын
Thanks for the nice video. After saving the settings, I have to close and re-open the program otherwise saved settings do not work even I can see .conf already saved with new information! Is there anything that I can do: save and setting applies?
@foxlearn
@foxlearn 4 жыл бұрын
You should copy your program to another folder. each time you rebuild your project all data in the debug folder will be deleted.
@SiakNiTonying
@SiakNiTonying 7 жыл бұрын
Error 1 'Connection.Sqlhelper.IsConnection.get': not all code paths return a value c:\users\anthony\documents\visual studio 2013\Projects\Connection\Connection\SQLHELPER.cs 22 13 Connection what to do?
@panda3131
@panda3131 2 жыл бұрын
how is it implemented in the main form?
@Rasim_93
@Rasim_93 6 жыл бұрын
Thank you :)
@SystemServer
@SystemServer 4 жыл бұрын
Thanks. How to worked with XAF as same as it; Lesson Please....
@foxlearn
@foxlearn 4 жыл бұрын
OK. Thank you for your suggestion !
@johnchen0213
@johnchen0213 6 жыл бұрын
are you a robot? who made this music? I'm impressed....
@FelixSamora
@FelixSamora 7 жыл бұрын
Hola, Saludos ! Donde puedo descargar el proyecto ? , Gracias !
@queirozquery5734
@queirozquery5734 3 жыл бұрын
Need Help, Make a tutorial showing the use of (two connection strings) connection with Local and Remote database in C # language. Thanks!
@foxlearn
@foxlearn 3 жыл бұрын
Not change
@ngocluunguyenbao4490
@ngocluunguyenbao4490 6 жыл бұрын
Dear sir/madam! I can't save the changes to app.config! Please help me :(
@foxlearn
@foxlearn 6 жыл бұрын
Please check your code again. Try to run your app as administrator. Thank you
@MrSyed33
@MrSyed33 7 жыл бұрын
Hello Fox, The code runs smoothly but my connection string is not updated when i press the save button even though the message box says that it has been successfully saved. pls help
@johnreytungul4188
@johnreytungul4188 6 жыл бұрын
This will work once you publish/made a .exe of your application.
@homeyasamal8474
@homeyasamal8474 5 жыл бұрын
Fox learn super
@foxlearn
@foxlearn 5 жыл бұрын
Thank you so much !
@harysetiawan3005
@harysetiawan3005 5 жыл бұрын
Wooww..keren = great !
@foxlearn
@foxlearn 5 жыл бұрын
Thank you so much !
@gilbertoasuaje6763
@gilbertoasuaje6763 7 жыл бұрын
Once it is already packaged with the VisualStudio wrapper, could you use this tool to change the configuration of the connection string? Or is there a way to create a text file and that there is the connection string? Thanks for these videos, they helped me a lot. and I apologize for my English
@foxlearn
@foxlearn 7 жыл бұрын
Hi, You can go app.config to change the connection string. Thanks
@shehrozimran
@shehrozimran 4 жыл бұрын
HI Fox learn Team, string connectionString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};", txtcomboBox.Text, Databasetxt.Text, usertxt.Text, passwordtxt.Text); in this code my connection STring return null . Can you tell me why?
@foxlearn
@foxlearn 4 жыл бұрын
Please check your code again. I think you miss something
@shehrozimran
@shehrozimran 4 жыл бұрын
@@foxlearn i copied all your code but connectionstring variable receive null as i do debugging
@RamanjaneyuluKondaru
@RamanjaneyuluKondaru 3 жыл бұрын
It can't save the config file in the network installation... please help us to save the config file details in network location Thanks
@foxlearn
@foxlearn 3 жыл бұрын
I think you should run your app as administrator
@samael8100
@samael8100 6 жыл бұрын
can you create a tutorial for vbdotnet?
@noobz186
@noobz186 4 жыл бұрын
Can you show this in web application? Much appreciated!
@foxlearn
@foxlearn 4 жыл бұрын
OK. Thank you for your suggestion.
@user-hl1ss9lx4u
@user-hl1ss9lx4u 6 жыл бұрын
Unfortunately this method doesn't work for me .. Can you send me source code ?
@user-ym8fn3bk6l
@user-ym8fn3bk6l 6 жыл бұрын
Yes it is true
@Ranjithkumar-tr1mh
@Ranjithkumar-tr1mh 7 жыл бұрын
Hi, I cant access the file. It is saying that access to the path is denied. Any solution for this will be appreciated.
@foxlearn
@foxlearn 7 жыл бұрын
Hi, You need to select your application run as administrator. Thanks
@shooterrick1
@shooterrick1 5 жыл бұрын
What is the cboServer? I don't understand where that came from.
@foxlearn
@foxlearn 5 жыл бұрын
cboServer is a name of combobox control
@elifgozdeklc9694
@elifgozdeklc9694 5 жыл бұрын
How can the current connection string be called in a different form? How to associate with an SQL query? SqlCommand cmd= new SqlCommand("Select HOST from BAGLANTI where ID=@p1", helper ??);
@foxlearn
@foxlearn 5 жыл бұрын
Change your connectionstring in the app.config file
@ArunTr
@ArunTr 4 жыл бұрын
Elif connection stringi yapamadim bana yardimci olurmusun?
@michaelmashigwana4669
@michaelmashigwana4669 3 жыл бұрын
Please help with this : Using windows form project write a C# application and make use of CRUD (Create, Read, Update and Delete) to include a Search function, Read function, Update function and delete function. Take Students as a Data Source (with its properties) and perform LINQ queries on this. All the CRUD procedures should be done on the C# IDE and update the information on the SQL Server database as well. Students are allowed to use different properties and colors, to make the application more real world like.
@softer.prakashmishra8040
@softer.prakashmishra8040 Жыл бұрын
Keyword not supported
@DaveJamesTech
@DaveJamesTech 7 жыл бұрын
how i can used this tutorial with entity framework? thanks this is great tutorial
@foxlearn
@foxlearn 7 жыл бұрын
Hi, You can create a config form and use this code to save your connection string when using entity framework, Thank
@DaveJamesTech
@DaveJamesTech 7 жыл бұрын
thanks for the tip
@DaveJamesTech
@DaveJamesTech 7 жыл бұрын
not working on entity framework. please help me
@foxlearn
@foxlearn 7 жыл бұрын
You should use entity framework code first, Thank you
@Saobranaung
@Saobranaung 7 жыл бұрын
Thanks
@goodluckcomputershorthandc4305
@goodluckcomputershorthandc4305 5 жыл бұрын
error Keyword not supported: 'datasource' Showing this error msg when I click connect button.
@goodluckcomputershorthandc4305
@goodluckcomputershorthandc4305 5 жыл бұрын
any body can reply
@nouriyacine8823
@nouriyacine8823 4 жыл бұрын
why u didn't upload the code in the description ?
@foxlearn
@foxlearn 4 жыл бұрын
You can find demo at foxlearn.com . Thank you !
@sherwinmanguilin1173
@sherwinmanguilin1173 7 жыл бұрын
hi fox learn good day im wondering if how can i use the connection with this tutorial thanks
@sherwinmanguilin1173
@sherwinmanguilin1173 7 жыл бұрын
i mean on how can i use it in selecting updating and etc
@foxlearn
@foxlearn 7 жыл бұрын
Hi, You can view more at: kzbin.info/aero/PL-EU0JUF-XD2qtVK0pOkCeWLUbnnnMo0k . Thank you !
@sherwinmanguilin1173
@sherwinmanguilin1173 7 жыл бұрын
+Fox Learn ok thanks!! can i have all your examples insert update delete, user authenticate with sql server including this my email is manguilins@gmail.com thankyou verymuch!!
@rahulsharma-tm4ye
@rahulsharma-tm4ye 6 жыл бұрын
dear sir/mam i am getting keyword not supported :"datasource' error please help me to solve while connecting with sa password
@foxlearn
@foxlearn 6 жыл бұрын
Please check your connection string again. You should enter your server name, user name and password of your sql account
@adelmerhej4194
@adelmerhej4194 5 жыл бұрын
It should be "Data Source" and NOT "DataSource"
@fademaydarkness1017
@fademaydarkness1017 4 жыл бұрын
object reference not set to an instance of an object while saving
@foxlearn
@foxlearn 4 жыл бұрын
Please check your connection string name
@gilbertoasuaje6763
@gilbertoasuaje6763 7 жыл бұрын
Excuse me, i did not realize it. Hi, i hope these
@foxlearn
@foxlearn 7 жыл бұрын
You're welcome. Thank you so much
@j.r.4938
@j.r.4938 8 жыл бұрын
Hello, some tutorial for a login with Facebook.
@foxlearn
@foxlearn 8 жыл бұрын
ok. thank you for your suggestion
@Jesus72188
@Jesus72188 5 жыл бұрын
Me gustaría un vídeo con access 2016 y Vb.net 2017
@foxlearn
@foxlearn 5 жыл бұрын
OK. Thank you for your suggestion. I'll upload all videos using vb.net as soon as possible !
@Jesus72188
@Jesus72188 5 жыл бұрын
@@foxlearn Thank you
@charli384
@charli384 4 жыл бұрын
config.ConnectionStrings.ConnectionStrings[key].ConnectionString = 'config.ConnectionStrings.ConnectionStrings[key].ConnectionString' error: 'System.NullReferenceException'
@foxlearn
@foxlearn 4 жыл бұрын
Please check your connection string in the app.config file. thank you !
@cut1e_
@cut1e_ 4 жыл бұрын
@@foxlearn An unhandled exception of type 'System.NullReferenceException' Error in this line config.ConnectionStrings.ConnectionStrings[key].ConnectionString = value; What exactly do I need to fix? connectionString="Data Source=DESKTOP-65QMQGS\SQLEXPRESS;Initial Catalog=uchhet_izm;Integrated Security=True?;" Please answer me, it is very important for me
@cut1e_
@cut1e_ 4 жыл бұрын
@@foxlearn I found my mistake, I had a different form name. In general, thank you very much for the video, I suffered for a very long time until I found you)
هذه الحلوى قد تقتلني 😱🍬
00:22
Cool Tool SHORTS Arabic
Рет қаралды 31 МЛН
拉了好大一坨#斗罗大陆#唐三小舞#小丑
00:11
超凡蜘蛛
Рет қаралды 6 МЛН
How to Store and Retrieve Setting  In WPF
28:05
Tactic Devs
Рет қаралды 11 М.
How to store  connection string of Database in app.config file?
10:41
CodingByAdnanQurban
Рет қаралды 58 М.
How to Encrypt and Decrypt Connection Strings in .Net app.config and web.config Files
19:38
Sean MacKenzie Data Engineering
Рет қаралды 21 М.
c# tutorial for beginners| connect C# with selected MS access database (accdb and mdb)
25:05
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 354 М.
dynamic Config SQL Connection For C# Apps
27:19
C# Code Academy
Рет қаралды 7 М.