c# sql 연결하는 법
nuget 패키지 로 system.data.sqlclient 를 설치하여 프로젝트에 참조시킨다.
using system.data.sqlclient
string strConn = "Data Source=IP,port;Initial Catalog=DataBase;User ID=id;Password=pw";
SqlConnection sqlConn = new SqlConnection(strConn);
sqlConn.Open();
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = sqlConn;
myCommand.CommandText = "query";
myCommand.ExecuteNonQuery();
sqlConn.Close();
|
cs |
728x90
반응형
'c#' 카테고리의 다른 글
[C#] 실무에서 DB 연동 시 Full ORM 잘 사용하지 않는 이유 (0) | 2025.02.13 |
---|---|
c# KeepAlive 구현 (0) | 2024.09.23 |
[WPF/WINUI3] stackpanel in datagrid speed (0) | 2024.05.26 |
IIS blazor 배포하기 (web deploy 3.6) (0) | 2022.09.13 |