50٪ تخفیف روی تمام دوره‌ها!
پایان تخفیف تا:
مشاهده دوره‌ها
0

مشکل اتصال به sql server در سی شارپ

سلام ببخشد من Sql Server رو نصب کردم و می خوام با سی شارپ به هش وصل بشم و از databaseام جدول بگیرم erro میده:

System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'

Win32Exception: The system cannot find the file specified

و نمی تونم بهش اصال پیدا کنم و کد هم : 

            string query = "Select * From amma";
            SqlConnection connection = new SqlConnection(connectionString);
            SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
            DataTable data = new DataTable();
            adapter.Fill(data);
            return data;

و این هم string که برای مشخصاته "Data Source = (local); Initial Catalog = amma; Integrated Security = SSPI"

پرسیده شده در 1399/04/10 توسط

1 پاسخ

1

سلام. ConnectionString رو به صورت زیر تغییر بدید:

Data Source=.; Initial Catalog = amma; Integrated Security = SSPI
پاسخ در 1399/04/10 توسط

پاسخ شما