TABLE을 생성하는 함수를 만들어 봤다.
TEXT상자 이름은 tbName이고, Label의 이름은 checkL이다.
tbName을 잘 읽는지 시험하려고 만는 Label은 그렇게 큰 의미는 없다.
Me.tbName.Text를 Create Table 할 때, 이름으로 지정하면 된다.
Private Function OpenDbFortable() As Boolean
On Error Resume Next
' 에러가 발생하면 쉽게 종료하기 위해 에러 조건
' 에 대한 리턴 값을 설정한다.
OpenDbFortable = False
checkL.Caption = Me.tbName.Text
If Me.tbName.Text = "" Then 'if문을 이용해 쿼리가 error나지 않을 최소조건(공백체크)을 설정 한다.
'에러메세지
MsgBox "txt상자에 글자가 없습니다."
Exit Function
Else
If gobjConnection.State = adStateClosed Then
' 포켓 액세스 데이터베이스 오픈
gobjConnection.Open CD_CDB_PATH_FILENAME
End If
' text상자에 쓴 이름으로 테이블 생성
gobjConnection.Execute "CREATE TABLE '" & Me.tbName.Text & "'" _
& "(NoId int, PoName varchar(64), PoTarget varchar(64), PoState varchar(100), PoProgress int, PoSideEffect varchar(100), PoExpire varchar(64), PoReference varchar(100), PoPrepro varchar(100), PoIcon varchar(64), PoLateDay int)"
End If
If Err.Number = 0 Then
OpenDbFortable = True
End If
End Function
--------------------쿼리만 바꾼 table 지우는 함수 ------------------
Private Function CloseDbFortable() As Boolean '''''''''''''테이블을 지우는 함수입니다. !!!
On Error Resume Next
' 에러가 발생하면 쉽게 종료하기 위해 에러 조건
' 에 대한 리턴 값을 설정한다.
CloseDbFortable = False
checkL.Caption = Me.tbName.Text
If Me.tbName.Text = "" Then 'if문을 이용해 쿼리가 error나지 않을 최소조건(공백체크)을 설정 한다.
'에러메세지
MsgBox "txt상자에 글자가 없습니다."
Exit Function
Else
If gobjConnection.State = adStateClosed Then
' 포켓 액세스 데이터베이스 오픈
gobjConnection.Open CD_CDB_PATH_FILENAME
End If
' text상자에 쓴 이름으로 테이블 제거
gobjConnection.Execute "drop TABLE '" & Me.tbName.Text & "'"
End If
If Err.Number = 0 Then
CloseDbFortable = True
End If
End Function
TEXT상자 이름은 tbName이고, Label의 이름은 checkL이다.
tbName을 잘 읽는지 시험하려고 만는 Label은 그렇게 큰 의미는 없다.
Me.tbName.Text를 Create Table 할 때, 이름으로 지정하면 된다.
Private Function OpenDbFortable() As Boolean
On Error Resume Next
' 에러가 발생하면 쉽게 종료하기 위해 에러 조건
' 에 대한 리턴 값을 설정한다.
OpenDbFortable = False
checkL.Caption = Me.tbName.Text
If Me.tbName.Text = "" Then 'if문을 이용해 쿼리가 error나지 않을 최소조건(공백체크)을 설정 한다.
'에러메세지
MsgBox "txt상자에 글자가 없습니다."
Exit Function
Else
If gobjConnection.State = adStateClosed Then
' 포켓 액세스 데이터베이스 오픈
gobjConnection.Open CD_CDB_PATH_FILENAME
End If
' text상자에 쓴 이름으로 테이블 생성
gobjConnection.Execute "CREATE TABLE '" & Me.tbName.Text & "'" _
& "(NoId int, PoName varchar(64), PoTarget varchar(64), PoState varchar(100), PoProgress int, PoSideEffect varchar(100), PoExpire varchar(64), PoReference varchar(100), PoPrepro varchar(100), PoIcon varchar(64), PoLateDay int)"
End If
If Err.Number = 0 Then
OpenDbFortable = True
End If
End Function
--------------------쿼리만 바꾼 table 지우는 함수 ------------------
Private Function CloseDbFortable() As Boolean '''''''''''''테이블을 지우는 함수입니다. !!!
On Error Resume Next
' 에러가 발생하면 쉽게 종료하기 위해 에러 조건
' 에 대한 리턴 값을 설정한다.
CloseDbFortable = False
checkL.Caption = Me.tbName.Text
If Me.tbName.Text = "" Then 'if문을 이용해 쿼리가 error나지 않을 최소조건(공백체크)을 설정 한다.
'에러메세지
MsgBox "txt상자에 글자가 없습니다."
Exit Function
Else
If gobjConnection.State = adStateClosed Then
' 포켓 액세스 데이터베이스 오픈
gobjConnection.Open CD_CDB_PATH_FILENAME
End If
' text상자에 쓴 이름으로 테이블 제거
gobjConnection.Execute "drop TABLE '" & Me.tbName.Text & "'"
End If
If Err.Number = 0 Then
CloseDbFortable = True
End If
End Function
댓글 달기