📄 msdbtest.ebf
字号:
VERSION 5.00
Begin VB.Form Form1
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "Form1"
ClientHeight = 3510
ClientLeft = 60
ClientTop = 840
ClientWidth = 3480
ForeColor = &H80000008&
ScaleHeight = 3510
ScaleWidth = 3480
ShowOK = -1 'True
Begin VBCE.CommandButton Command4
Height = 255
Left = 360
TabIndex = 5
Top = 2520
Width = 975
_cx = 1720
_cy = 450
BackColor = 12632256
Caption = "Insert Data"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.TextBox Text2
Height = 375
Left = 2160
TabIndex = 4
Top = 2160
Width = 1215
_cx = 2143
_cy = 661
BackColor = -2147483643
BorderStyle = 1
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "TAM-Abhirami"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Text = "Text2"
Alignment = 0
HideSelection = -1 'True
Locked = 0 'False
MaxLength = 0
MultiLine = 0 'False
PasswordChar = ""
ScrollBars = 0
End
Begin VBCE.TextBox Text1
Height = 375
Left = 2160
TabIndex = 3
Top = 1200
Width = 1215
_cx = 2143
_cy = 661
BackColor = -2147483643
BorderStyle = 1
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "TAM-Abhirami"
Size = 9
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = -2147483640
Text = "Tamil"
Alignment = 0
HideSelection = -1 'True
Locked = 0 'False
MaxLength = 0
MultiLine = 0 'False
PasswordChar = ""
ScrollBars = 0
End
Begin VBCE.CommandButton Command3
Height = 255
Left = 360
TabIndex = 2
Top = 1800
Width = 1335
_cx = 2355
_cy = 450
BackColor = 12632256
Caption = "RunQuery"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.CommandButton Command2
Height = 255
Left = 360
TabIndex = 1
Top = 1200
Width = 1335
_cx = 2355
_cy = 450
BackColor = 12632256
Caption = "CreatTBL"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
Begin VBCE.CommandButton Command1
Height = 255
Left = 360
TabIndex = 0
Top = 600
Width = 1335
_cx = 2355
_cy = 450
BackColor = 12632256
Caption = "CreateDB"
Enabled = -1 'True
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Style = 0
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'Public Declare Function WideCharToMultiByte Lib " coredll.dll" _
'(ByVal CodePage As Long, _
'ByVal Flags As Long, _
'ByVal MultiByteStr As String, _
'ByVal MultiByteStrSize As Long, _
'ByVal WideCharStr As String, _
'ByVal WideCharStrSize As Long, _
'ByVal lpDefaultChar As String, _
'ByVal lpUsedDefaultChar As Boolean) As Long
'
'Public Declare Function MultiByteToWideChar Lib " Coredll" _
'(ByVal CodePage As Long, _
'ByVal dwFlags As Long, _
'ByVal lpMultiByteStr As String, _
'ByVal cchMultiByte As Long, _
'ByVal lpWideCharStr As String, _
'ByVal cchWideChar As Long) As Long
'Function Format_to_ANSI(wide_string As String) As String
''' WideCharToMultiByte
''Dim strAnsi
''Dim strAnsiLen As Long
''strAnsiLen = WideCharToMultiByte(0, 0, wide_string, Len(wide_string), strAnsi, 0, 0, 0)
''strAnsi = Space(strAnsiLen) ' allocate a string for ansi string.
''strAnsiLen = WideCharToMultiByte(0, 0, wide_string, Len(wide_string), strAnsi, strAnsiLen, 0, 0)
''Format_to_ANSI = strAnsi
''End Function
'
'Function Format_to_ANSI(wide_string As String, truncate As Boolean) As String
'Dim strAnsi
'Dim strAnsiLen As Long
'strAnsiLen = WideCharToMultiByte(0, 0, wide_string, Len(wide_string), strAnsi, 0, 0, 0)
'strAnsi = Space(strAnsiLen) ' allocate a string for ansi string.
'strAnsiLen = WideCharToMultiByte(0, 0, wide_string, Len(wide_string), strAnsi, strAnsiLen, 0, 0)
'If truncate Then strAnsi = Mid(strAnsi, 1, Len(strAnsi) / 2)
'Format_to_ANSI = strAnsi
'End Function
'Function Format_to_UNICODE(multiByteData As String) As String
'
'' MultiByteToWideChar
'' 1) code Page used for conversion CP_ACP = 0
'' 2) Flag Contants
'' 3) Data To be Converted
'' 4) -1 The Data To be Converted is to be null terminated and returns Length
'' 5) To be Translated String
'' 6) The length of the receiving buffer ..if 0 returns the size of 5
'
'Dim wideCharData As String
'Dim wideCharDataLen As Long
'Dim rc As Long
'wideCharData = " "
'wideCharDataLen = MultiByteToWideChar(0, 0, multiByteData, -1, vbNullString, 0)
'wideCharData = String(wideCharDataLen, " ")
'rc = MultiByteToWideChar(0, 0, multiByteData, -1, wideCharData, wideCharDataLen)
'Format_to_UNICODE = wideCharData
'End Function
Private Sub Command1_Click()
'On Error GoTo ErrSub
Dim cat As ADOXCE.Catalog
'Set cat = CreateObject("ADOXCE.Catalog.2.0")
Set cat = CreateObject("ADOXCE.Catalog.3.1")
'cat.Create ("Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0; data source=DBTest.sdf")
'cat.Create ("Provider=Microsoft.SQLSERVER.OLEDB.CE.3.1; data source=DBTest.sdf")
cat.Create "Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=DicDBTest.SDF"
'ErrSub
'If Err Then
'unexpectedError = True
' MsgBox "Error:-" + Err.Description + "," + Err.Number + "," + Err.LastDllError + "," + Err.Source, vbCritical
' Err.Clear
'End If
End Sub
Private Sub Command2_Click()
Dim str_Con As String
Dim cn As ADOCE.Connection
'str_Con = "Provider=Microsoft.SQLSERVER.OLEDB.CE.1.0; data source=\DBTest.sdf"
str_Con = "Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=DicDBTest.SDF"
Set cn = CreateObject("ADOCE.Connection.3.1")
cn.Open str_Con
cn.Execute "CREATE TABLE DicTBL(id int NOT NULL, EngWord nvarchar(50), TmlWord nvarchar(50))"
cn.Execute "CREATE UNIQUE INDEX idx1 ON DicTBL(id)"
cn.Execute "INSERT DicTBL VALUES(1, N'AAA', N'AAA')"
cn.Execute "INSERT DicTBL VALUES(2, N'CCC', N'BBB')"
cn.Execute "INSERT DicTBL VALUES(3, N'EEE', N'EEB')"
cn.Execute "INSERT DicTBL VALUES(4, N'ABC', N'ABC')"
cn.Close
Set cn = Nothing
MsgBox "Table Created!", vbOKCancel
End Sub
Private Sub Command3_Click()
Dim cn As ADOCE.Connection
Dim rs As ADOCE.Recordset
Dim str_Con As String
str_Con = "Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=DicDBTest.SDF"
Set cn = CreateObject("ADOCE.Connection.3.1")
Set rs = CreateObject("ADOCE.Recordset.3.1")
cn.Open str_Con
rs.Open "SELECT * FROM DicTBL", cn, adOpenKeyset, adLockReadOnly
While Not rs.EOF
'MsgBox rs.Fields.Item(1).Value + ", " + rs.Fields.Item(2).Value
MsgBox rs.Fields.Item("EngWord").Value + ", " + rs.Fields.Item("TmlWord").Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Private Sub Command4_Click()
Dim str_Con, strQry, strSrc, strtmp1 As String
Dim cn As ADOCE.Connection
Dim rs As ADOCE.Recordset
str_Con = "Provider=Microsoft.SQLServer.OLEDB.CE.2.0;Data Source=DicDBTest.SDF"
Set cn = CreateObject("ADOCE.Connection.3.1")
Set rs = CreateObject("ADOCE.Recordset.3.1")
cn.Open str_Con
rs.Open "SELECT * FROM DicTBL", cn, adOpenKeyset, adLockReadOnly
strSrc = Text1.Text
'Dim i As Integer
strtmp1 = rs.RecordCount + 1
strQry = "INSERT DicTBL VALUES(" & strtmp1 & "," & "N'" & strSrc & "'" & "," & "N'" & strSrc & "'" & ")"
cn.Execute strQry
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
Private Sub Command5_Click()
Dim hFile As Long
Dim MyString As String
MyString = ""
MyString = Format_to_UNICODE(" Hello there!")
MyString = " Hello There!"
MyString = Format_to_ANSI(" Hello there!")
' Now call the API function to create the file:
'hFile = CreateFile(" MyTestFile.txt", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0)
' Write to the file:
'If hFile <> -1 Then
' WriteFile hFile, MyString, LenB(MyString), lWritten, 0
' CloseHandle hFile ' Always use CloseHandle with CreateFile to close the file.
'End If
End Sub
Private Sub Form_OKClick()
App.End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -