Dim SqlDs As New DataSet Dim Conn As New SqlConnection(SQLNativeConnStr) Conn.Open() Dim SQLStr As String = "SELECT * FROM " & TableName & "" Dim SqlAdp As SqlDataAdapter = New SqlDataAdapter(SQLStr, Conn) SqlAdp.Fill(SqlDs) Conn.Close() Dim dt As DataTable = SqlDs.Tables(0) 'Dim OleDbCon As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileLoadPath & ";") 'OleDbCon.Open() 'Dim OleDbCmd As OleDbCommand = New OleDbCommand(MdbTableScript, OleDbCon) 'OleDbCmd.ExecuteNonQuery() 'OleDbCon.Close() Dim SqlQuery As String = "SELECT * FROM [" & TableName & "]" Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileLoadPath & ";" Dim Adapter As New OleDbDataAdapter(SqlQuery, ConnString) Dim CmdBuilder As New OleDbCommandBuilder(Adapter) CmdBuilder.QuotePrefix = "[" CmdBuilder.QuoteSuffix = "]" Dim ds As New DataSet Adapter.FillSchema(ds, SchemaType.Source) ds.Tables(0).TableName = "Temp" For i As Integer = 0 To dt.Rows.Count - 1 Dim RowValues(ds.Tables(0).Columns.Count - 1) As Object For j As Integer = 0 To ds.Tables(0).Columns.Count - 1 If dt.Rows(i)(j).ToString().ToUpper() = "" Then If ds.Tables(0).Columns(j).DataType.ToString() = "System.String" Then RowValues(j) = "" Else RowValues(j) = 0 End If Else RowValues(j) = dt.Rows(i)(j).ToString() End If Next ds.Tables(0).Rows.Add(RowValues) Next Adapter.Update(ds, "Temp") Adapter.Dispose()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)