Δεν είναι σαφές, πώς όταν λέω ότι χρησιμοποιώ κώδικα VB.NET, ότι οι driver είναι του .NET ?
Στο πρώτο post, είπα MDAC. Και τα ίδια φαινόμενα παρουσιάζονται είτε στο VB-2005, είτε
στο VB-2012. Δεν υπάρχουν ndx αρχεία. Δεν χρησιμοποιούνται παρά μόνο:
α) ένα DBF και
β) ένα VB.NET source που διαβάζει αυτό το DBF
ΚΩΔΙΚΑΣ:
***********************************************************************
Imports System.io
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbConnection
Imports System.Data.Odbc
Imports System.Data.Odbc.OdbcConnection
Public Class Form1
Dim command As OdbcCommand
Dim dr As OdbcDataReader
Dim connection As OdbcConnection
Dim connectionString As String = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=d:\station;"
Dim sql As String = "SELECT * FROM ALARMS WHERE DISPATCH LIKE '?'"
Dim command1 As OleDbCommand
Dim dr1 As OleDbDataReader
Dim connection1 As OleDbConnection
Dim connectionString1 As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\STATION; Extended Properties=dBase III"
Dim sql1 As String = "SELECT * FROM ALARMS WHERE DISPATCH LIKE '?' "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim counter As Integer = 0
connection1 = New OleDbConnection(connectionString1)
connection1.Open()
command1 = New OleDbCommand(sql1, connection1)
dr1 = command1.ExecuteReader
Dim locstring As Byte()
Dim strModified As String = ""
While (dr1.Read())
locstring = System.Text.Encoding.GetEncoding(0).GetBytes(dr1.GetValue(4).ToString())
strModified = System.Text.Encoding.GetEncoding(737).GetString(locstring)
TextBox1.AppendText(dr1.GetValue(0).ToString() & " " & dr1.GetValue(1).ToString().Substring(0, 10) & " " & _
dr1.GetValue(2).ToString() & " " & dr1.GetValue(3).ToString() & " " & _
strModified.PadRight(49, " ") & _
dr1.GetValue(5).ToString() & vbCrLf)
'dr1.GetValue(4).ToString().PadRight(49, " ") & _
counter += 1
If counter = 1000 Then
Exit While
End If
End While
connection1.Close()
dr1.Close()
command1.Dispose()
connection1.Dispose()
TextBox1.AppendText(vbCrLf & " END " & vbCrLf)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim counter As Integer = 0
connection = New OdbcConnection(connectionString)
connection.Open()
command = New OdbcCommand(sql, connection)
dr = command.ExecuteReader
Dim locstring As Byte()
Dim strModified As String = ""
While (dr.Read())
locstring = System.Text.Encoding.GetEncoding(0).GetBytes(dr.GetValue(4).ToString())
strModified = System.Text.Encoding.GetEncoding(737).GetString(locstring)
TextBox1.AppendText(dr.GetValue(0).ToString() & " " & dr.GetValue(1).ToString().Substring(0, 10) & " " & _
dr.GetValue(2).ToString() & " " & dr.GetValue(3).ToString() & " " & _
strModified.PadRight(49, " ") & _
dr.GetValue(5).ToString() & vbCrLf)
'dr.GetValue(4).ToString().PadRight(49, " ") & _
counter += 1
If counter = 5 Then
Exit While
End If
End While
connection.Close()
dr.Close()
command.Dispose()
connection.Dispose()
TextBox1.AppendText(vbCrLf & " END " & vbCrLf)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim counter As Integer = 0
Dim sConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\station;Extended Properties=dBase IV"
Dim objConn As New System.Data.OleDb.OleDbConnection(sConnectionString)
objConn.Open()
Dim da As New System.Data.OleDb.OleDbDataAdapter("Select * from alarms WHERE DISPATCH LIKE '?'", objConn)
Dim ds As New DataSet("temporal")
da.Fill(ds, "temporal")
Dim dt As DataTable = ds.Tables("temporal")
Dim drCurrent As DataRow
For Each drCurrent In dt.Rows
TextBox1.AppendText(drCurrent(0).ToString & " " & _
drCurrent(1).ToString.Substring(0, 10) & " " & _
drCurrent(2).ToString & " " & _
drCurrent(3).ToString & " " & _
drCurrent(4).ToString & " " & _
drCurrent(5).ToString & vbCrLf)
Dim mystr As String = ""
For Each mystr In drCurrent(4).ToString
TextBox1.AppendText(Asc(mystr) & " ")
Next
counter += 1
If counter = 1 Then
Exit For
End If
Next
objConn.Close()
TextBox1.AppendText(vbCrLf & " END " & vbCrLf)
End Sub
End Class
****************************************************** ΚΑΙ Η ΑΠΑΝΤΗΣΗ ******************
23E4 01/11/2012 00:29 0 ΔΕ? ΕΧΕ? ΕΡΘΕ? ΣΗΜΑ ΑΠZ -> 30/10/12 - 17.33- ?
2ED5 01/11/2012 00:29 0 ΔΕ? ΕΧΕ? ΕΡΘΕ? ΣΗΜΑ ΑΠZ -> 30/10/12 - 17.46- ?
CB76 01/11/2012 00:29 0 ΔΕ? ΕΧΕ? ΕΡΘΕ? ΣΗΜΑ ΑΠZ -> 30/10/12 - 17.48- ?
DD42 01/11/2012 00:29 0 ΔΕ? ΕΧΕ? ΕΡΘΕ? ΣΗΜΑ ΑΠZ -> 30/10/12 - 17.50- ?