by Jan Lovfol (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 28th July 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Read Query-strings from ini file. Useful to import Postal Codes into tables. Requires one form and one module (*.bas)
API Declarations
Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
'Get Section Data From <inifile>
Public Function GetSectionFromMini(SectionName As String, Filename As String, b_sData$)
On Error GoTo Proc_Err
Dim SectionData As String
Dim Length As Long
SectionData = String(9000000, 0)
Length = GetPrivateProfileSection(SectionName$, SectionData, 9000000, Filename)
b_sData = Left(SectionData, Length)
Proc_Exit:
Exit Function
Proc_Err:
MsgBox "Unexpected Error in Procedure GetSectionFromMini:" & CStr(Err.Number) & ":" & Err.Description
Resume Proc_Exit
End Function
Dim prefix As String
Dim username As String
Dim password As String
Dim dsn As String
Dim message As String
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim delete As String
Dim i As Integer
Dim sData As String
Set Conn = New ADODB.Connection
Set rs = New ADODB.Recordset
username = txtusername.Text
password = txtpassword.Text
dsn = txtodbc.Text
delete = "delete from <>table"
prefix = txtprefix.Text
i = 1
Conn.Open "Provider=MSDASQL.1;Password=" & password & ";Persist Security Info=True;User ID=" & username & " ;Data Source=" & dsn & ""
rs.Open delete, Conn, adOpenKeyset, adLockOptimistic, adCmdText
GetSectionFromMini "postalupdate", App.Path & "\ZIPTOCITY.INI", sData
Dim pos%
Do
pos = InStr(1, sData, Chr(0), vbTextCompare)
sData = Mid(sData, pos + 1)
rs.Open sData, Conn, adOpenKeyset, adLockOptimistic, adCmdText
i = i + 1
Loop While Not i = 4611
message = MsgBox(" " & i & " records imported successfully", vbOKOnly, "Postal Update")
End Sub
No comments have been posted about Read Query-strings from ini file. Useful to import Postal Codes into tables. Requires one form and . Why not be the first to post a comment about Read Query-strings from ini file. Useful to import Postal Codes into tables. Requires one form and .