Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this is my connection string
string conn = string.Empty;
conn = "DataSource=localhost;DATABASE=learning;USER ID=root;PASSWORD=admin;";
SqlConnection connection = new SqlConnection(conn);
connection.Open();
string cmd = "SELECT * FROM person_det;";
SqlCommand cmnd = new SqlCommand(cmd);
while i try to compile i got this error "Keyword not supported: 'datasource'." in this line "SqlConnection connection = new SqlConnection(conn);"
Posted

If you're using that format of connection string, it's not "DataSource", but "Data Source" with a space in between. If you're ever unsure about a connection string, you need to check out this site:

http://www.connectionstrings.com/[^]
 
Share this answer
 
Hi,

Here is your mistake,

C#
conn = "DataSource=localhost;DATABASE=learning;USER ID=root;PASSWORD=admin;";


please Rewrite as
C#
conn = "Data Source=localhost;DATABASE=learning;USER ID=root;PASSWORD=admin;";


regards
sarva
 
Share this answer
 
v2

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