첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.

[VB] INSERT SQL 실행하기

VB 2015. 5. 15. 09:00
728x90
반응형
728x170
Dim pConnection     As ADODB.Connection
Dim pCommand        As ADODB.Command
Dim pParameter      As ADODB.Parameter
Dim nRecordAffected As Long

Set pConnection = GetMDBConnection("c:\test.mdb") ' "MDB 연결 구하기" 참조

If pConnection Is Nothing Then

    MsgBox "데이터베이스 파일 연결을 실패했습니다."
    
    Exit Sub

End If

Set pCommand = GetCommand(pConnection, adCmdText, True, "INSERT INTO Sample (ID, Name) VALUES (아이디, 명칭)") ' "명령 구하기" 참조

Set pParameter = AddParameter(pCommand, "아이디", adInteger, adParamInput, 2) ' "파라미터 추가하기" 참조

pParameter.Value = 4

Set pParameter = AddParameter(pCommand, "명칭", adVarChar, adParamInput, 50)

pParameter.Value = "라"

pCommand.Execute nRecordAffected

Print nRecordAffected

Set pCommand = Nothing

pConnection.Close

Set pConnection = Nothing
728x90
반응형
그리드형(광고전용)
Posted by icodebroker
TAG ,

댓글을 달아 주세요