Notice
Recent Posts
Recent Comments
분노의 챔질
C# DB연결하기 본문
반응형
string connectionString = @"Server=서버명;
user id=로그인ID;
password=비밀번호;
database=DATABASE이름;
Integrated Security=true;"; //윈도우인증일때 사용
password=비밀번호;
database=DATABASE이름;
Integrated Security=true;"; //윈도우인증일때 사용
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
string query = "Select * from dbo.Employee where EmployeeID = @EmployeeID";
SqlCommand command = new SqlCommand(query, conn);
//StoredProcedure 사용
// command.CommandType = CommandType.StoredProcedure;
/////////////////////
command.Connection = conn;
command.CommandTimeout = 0;
command.Parameters.Add("@EmployeeID", SqlDbType.NVarChar);
command.Parameters["@EmployeeID"].Value = "1";
command.ExecuteNonQuery();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(dt);
반응형
'Programming > C#' 카테고리의 다른 글
C# XML 만들기, 읽기 (0) | 2010.02.23 |
---|---|
C# 암호화 (0) | 2010.02.23 |
C# Assembly.LoadFrom() DLL불러오기 (0) | 2010.02.23 |
C# PDF파일 다루기 (1) | 2010.02.23 |
C# WebClient를 이용한 자동업데이트 (1) | 2010.02.23 |