QnA
|
사용언어
(칠해주세요) => (C#,VB) |
|
사용툴 (VS) : 비주얼ㅅ2013 |
|
운영체제 (OS) : 원도우 |
vb.net에서 data를 access에 저장,업데이터,삭제하려고 합니다.
primary key가 2개일때는 어떻게 해야하는지 알고싶어요.
primary key =>> UserNo, UserName입니다.
아래는 싱글 primary key일떄입니다.
<Insert>
With cmd
.Connection = conn
.CommandText = "Insert Into TblUser (UserNo,UserName,UserPassword) Values (@a0,@a1,@a2)"
.Parameters.Add("@a0", OleDbType.VarChar).Value = txtNo.Text
.Parameters.Add("@a1", OleDbType.VarChar).Value = txtName.Text
.Parameters.Add("@a2", OleDbType.VarChar).Value = txtPassword.Text
i = .ExecuteNonQuery()
.Dispose()
End With
<updata>
With cmd
.Connection = conn
.CommandText = "Update TblUser Set UserName=@a1,UserPassword=@a2 where UserNo= '" & txtNo.Text & "'"
.Parameters.Add("@a1", OleDbType.VarChar).Value = txtName.Text
.Parameters.Add("@a2", OleDbType.VarChar).Value = txtPassword.Text
i = .ExecuteNonQuery()
.Dispose()
End With
<<Delete>>
With cmd
.Connection = conn
.CommandText = "delete from TblUser where UserNo= '" & txtNo.Text & "'"
i = .ExecuteNonQuery()
End With
단일 Primary-key를 사용했을 경우를 입니다.
그럼 멀티키를 사용했을 경우는 어떻게 하는지 고수님의 조언부탁드려요
첫댓글 ..;;;
.CommandText = "delete from TblUser where UserNo= '" & txtNo.Text & "'" & " and UserName = '" & txtUserNm.Text & "'" 이겠죠?
덕분에 멀티키에 대한 지식을 알게되었네요
감사합니다.
Sql injection 공격을 받을수 있어요. 흠. 도움이 될진. ;) http://m.cafe.daum.net/aspdotnet/JTk/393?svc=cafeapp
감사합니다.
초보라 잘이해는 되지않지만 참고할께요 ^^