Author:
水如烟
总目录:
行政区划数据方案设计
上一篇,
行政区划数据数据库的设计(四)
以上所为在数据库做好了主体表及增加数据的存储过程。这次重新回到程序,目的是将数据导进数据库里面,因为在后面的数据库附属表的设计要用到这些数据,要边调试边设计。
现在的方案组织如下:
效果图:
增加的代码:
Constant.vb
Namespace
Database
Friend Class Constant
Private Sub New ()
End Sub
Public Const CONNECTIONSTRING As String = " Database=RegionalCodeWorks;Server=./SQLEXPRESS;Integrated Security=SSPI; "
Public Const PROCEDURE_ADDRECORD As String = " Program.增添记录 "
End Class
End Namespace
Friend Class Constant
Private Sub New ()
End Sub
Public Const CONNECTIONSTRING As String = " Database=RegionalCodeWorks;Server=./SQLEXPRESS;Integrated Security=SSPI; "
Public Const PROCEDURE_ADDRECORD As String = " Program.增添记录 "
End Class
End Namespace
UpdateDatabase.vb
Namespace
Database
Public Class UpdateDatabase
Public Event UpdateCompleted( ByVal sender As Object , ByVal msg As String )
Private gCommand As SqlClient.SqlCommand
Sub New ()
gCommand = GetCommand()
End Sub
Public Sub OpenConnection()
With gCommand.Connection
If .State <> ConnectionState.Open Then .Open()
End With
End Sub
Public Sub CloseConnection()
With gCommand.Connection
If .State = ConnectionState.Open Then .Close()
End With
End Sub
Public Sub Import( ByVal table As DataTable, ByVal lastdate As String )
Dim mCode As String
Dim mName As String
For Each row As DataRow In table.Rows
mCode = row.Item( " Code " ).ToString
mName = row.Item( " Name " ).ToString
ImportRecord(mCode, mName, lastdate)
Public Class UpdateDatabase
Public Event UpdateCompleted( ByVal sender As Object , ByVal msg As String )
Private gCommand As SqlClient.SqlCommand
Sub New ()
gCommand = GetCommand()
End Sub
Public Sub OpenConnection()
With gCommand.Connection
If .State <> ConnectionState.Open Then .Open()
End With
End Sub
Public Sub CloseConnection()
With gCommand.Connection
If .State = ConnectionState.Open Then .Close()
End With
End Sub
Public Sub Import( ByVal table As DataTable, ByVal lastdate As String )
Dim mCode As String
Dim mName As String
For Each row As DataRow In table.Rows
mCode = row.Item( " Code " ).ToString
mName = row.Item( " Name " ).ToString
ImportRecord(mCode, mName, lastdate)