Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
dear all


i am using this code

con=new sqlconnection ("server=local;database=master;uid=sa;pwd=")


please any one can tell how i xcan use this server name and database base name by combobox like bellow
combo box
server 1
server 2
server 3

then i can select server 1

and other

VB
combo box
database 1
database 2
database  3


then i can select database 2
Posted

1 solution

You can set like that.. :)

C#
SqlConnection cn = new SqlConnection("Data Source=" + cmbServer.Text + ";Initial Catalog=" + cmbDataBase.Text + ";User ID=sa;Password=*****");


You can use combobox selected value or text as you want.. :)
 
Share this answer
 
v2
Comments
irfanansari 2-Aug-14 7:14am    
dear i try it in class1 but it did not works
Nirav Prabtani 2-Aug-14 7:23am    
Dear it must work.. :)
Nirav Prabtani 2-Aug-14 7:24am    
Show me your code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900