Dim cCom As OleDb.OleDbCommandBuilder
Dim dSet As DataSet = New DataSet()
Dim dAdp As OleDb.OleDbDataAdapter
Dim ocn As OleDb.OleDbConnection = New OleDb.OleDbConnection()
Dim i As Integer
Dim PBAR As String
Dim Zip1 As String
Dim Zip2 As String
Dim x, y As Intger
ocn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\***.mdb;
Persist Security Info = False"
dAdp = New OleDb.OleDbDataAdapter(
"SELECT ID,郵便,住所,氏名,Zip,バーコード,SS,SSS FROM D", ocn)
dAdp.Fill( dSet, "t_D" )
Dim count As Integer = dSet.Tables("t_D").Rows.Count
For i = 0 To count - 1
dSet.Tables("t_D").Rows(i)("氏名") = dSet.Tables("t_D").Rows(i)("氏名") & " 様"
Dim z As Intger = CInt(dSet.Tables("t_D").Rows(i)("SS"))
if z <= 3 Then
dSet.Tables("t_D").Rows(i)("バーコード") = Nothing
ElseIf z >= 4 Then
PBAR = dSet.Tables("t_D").Rows(i)("PZIP") & dSet.Tables("t_D").Rows(i)("バーコード")
dSet.Tables("t_D").Rows(i)("バーゴード") = PBAR
End If
If z <= 3 Then
Dim aaa As String
aaa = dSet.Tables("t_D").Rows(i)("郵便") & ""
If y = 3 Then
Zip1 = aaa.SubString( 0 , 3 )
Zip2 = ""
ElseIf y = 5 Then
Zip1 = aaa.SubString( 0 , 3 )
Zip2 = aaa.SubString( 3 , 2 )
ElseIf y = 7 Then
Zip1 = aaa.SubString( 0 , 3 )
Zip2 = aaa.SubString( 3 , 4 )
Else
Zip1 = Nothing
Zip2 = Nothing
End If
x = StrComp( "" , Zip2 )
If x = 0 Then
aaa = Zip1
Else
aaa = Zip1 & "-" & Zip2
End If
dSet.Tables("t_D").Rows(i)("郵便") = aaa
dSet.Tables("t_D").Rows(i)("PZIP") = Nothing
dSet.Tables("t_D").Rows(i)("SS") = "2"
Else If z >= 4 Then
Zip1 = dSet.Tables("t_D").Rows(i)("PZIP").SubString( 0 , 3 )
Zip2 = dSet.Tables("t_D").Rows(i)("PZIP").SubString( 3 , 4 )
dSet.Tables("t_D").Rows(i)("郵便") = Zip1 & "-" & Zip2
dSet.Tables("t_D").Rows(i)("PZIP") = Nothing
dSet.Tables("t_D").Rows(i)("SS") = "1"
End If
Next
cCom = New OleDb.OleDbCommandBuilder(dAdp)
dAdp.Update( dSet , "t_D" )
ocn.Close()
0 件のコメント:
コメントを投稿