这个功能,可以考虑用smo对象来实现的,通过c#代码来实现。你可以参考一下这个:Smo类生成创建表的脚本语句
http://wenku.baidu.com/link?url=nE5yGi9k1dbJXvwVFAcbC7KXZojew0d20mlBRF8bHj6qwiGsUJt_TrZH3zbmhBHRKQnuXlWHe3fSdr2pQ6JzcQ0OGMUhzCgWSGPG8gYFXcq
http://wenku.baidu.com/link?url=nE5yGi9k1dbJXvwVFAcbC7KXZojew0d20mlBRF8bHj6qwiGsUJt_TrZH3zbmhBHRKQnuXlWHe3fSdr2pQ6JzcQ0OGMUhzCgWSGPG8gYFXcq
用SMO(sql server management object)生成创建表的脚本
http://www.cnblogs.com/geyunfei/archive/2010/05/13/1734339.html
Dim ExcelPathFile As String = "D:\Text\20131114.xls"
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ExcelPathFile + ";Extended Properties='Excel 8.0;HDR=NO;IMEX=1';"
Using connection As New OleDbConnection(ConnectionString)
Dim ds As New DataSet
Try
connection.Open()
Dim command As OleDbDataAdapter = New OleDbDataAdapter(Sql, connection)
command.Fill(ds, "ds")
Catch ex As System.Data.OleDb.OleDbException
Throw New Exception(ex.Message)
End Try
Return ds
End Using
End Function Public Sub ImportDataBaseInfo()
'根据excel里面的字段,可以导入创建个临时表,先导入到临时表,然后再导入到实体表
Dim i As Integer = 0
Dim dt As DataTable
Try
dt = OleHelper.Query("select * from Sheet1$").Tables(0)
Dim strRow1 As String
Dim strRow2 As String
For Each row As DataRow In dt.Rows
strRow1 = F.Left(ToStr(row(0)).Trim(), 30) strRow2 = F.Left(ToStr(row(1)).Trim(), 30)
'strRow3...............
If i = 0 Then
'验证下Excel字段列
If strRow1 <> "列1" Then
MsgBox("A列1")
Exit Sub
End If If strRow2 <> "列2" Then
MsgBox("B列不是列2")
Exit Sub
End If
Else
'SQL插入语句 临时表里面
End If
i += 1
Next
'数据检验,正确话 在导入到数据库中的实体表中.
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try End Sub