KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have created a SQL Server database called Database1.mdf in the App_Data folder in Visual Studio with a table called Names . How could I establish a connection to read the table values using C#? So far I've tried something like this: SqlConnection conn = new SqlConnection("Server=localhost;Database=Database1;"); conn.Open(); // create a SqlCommand object for this connection SqlCommand command = conn.CreateCommand(); command.CommandText = "Select * from Names"; But I get an error: database not found/error connecting to database
Tags (comma-separated)
Save Edits
Cancel