E
EMW
Hi,
Could you please take a look and tell me what this means?
Cor has tried to help me, but we haven't found it yet.
Everytime I run this code, I get an exception error.
Here is my code:
Dim connStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=" &
Me.txtFile.Text
Dim SQLstr As String = "SELECT * FROM sitelist"
Dim cn As New OleDb.OleDbConnection(connStr)
Dim da As New OleDb.OleDbDataAdapter(SQLstr, cn)
Dim ds As New DataSet
pgBar.Value = 0
pgBar.Refresh()
da.Fill(ds, "sitelist")
pgBar.Value += 1
pgBar.Refresh()
dgMain.DataSource = ds
dgMain.DataMember = "Sitelist"
dgMain.Refresh()
cn.Close()
'FileNaam = FileNaam.Replace("sitelijst.mdb", "sitelist.mdf")
Dim con As New SqlConnection("Server=(local);database=;Integrated
Security=SSPI")
Dim cmd1 As New SqlCommand("DROP DATABASE sitelist", con)
con.Open()
Try
cmd1.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim strSQL As String = "CREATE DATABASE sitelist"
Dim cmd2 As New SqlCommand(strSQL, con)
Try
cmd2.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
cmd2.CommandText = "USE sitelist " & vbCrLf & _
"CREATE TABLE sites (sitenummer NVARCHAR(10), " & _
"adres NVARCHAR(255), gemeente NVARCHAR(25), " & _
"[Type site] NVARCHAR(25), bsc NVARCHAR(35), " & _
"Safety NVARCHAR(25), [X pos] NVARCHAR(15), " & _
"[Y pos] NVARCHAR(15), verantwoordelijke NVARCHAR(25), " & _
"online NVARCHAR(15), CONSTRAINT [pk_indentFT] PRIMARY " & _
"KEY CLUSTERED(sitenummer))"
Try
cmd2.ExecuteNonQuery()
Catch ex As Exception
'do nothing
End Try
con.Close()
Dim sqlNewstr As String
con = New SqlConnection("Server=(local);Database=sitelist;Integrated
Security=SSPI;")
Dim sqlDa = New SqlDataAdapter
sqlDa.SelectCommand = New SqlCommand("SELECT * FROM sites", con)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(sqlDa)
cb.QuoteSuffix = "["
cb.QuotePrefix = "]"
Dim dstoo As New DataSet
sqlDa.Fill(dstoo, "Sites") 'connect the dataset to the empty table
Dim ab As Integer
Dim dr As DataRow
For ab = 0 To ds.Tables(0).Rows.Count - 1
dr = dstoo.Tables(0).NewRow()
dr(0) = ds.Tables(0).Rows(ab)(0)
dr(1) = ds.Tables(0).Rows(ab)(1)
dr(2) = ds.Tables(0).Rows(ab)(2)
dr(3) = ds.Tables(0).Rows(ab)(3)
dr(4) = ds.Tables(0).Rows(ab)(4)
dr(5) = ds.Tables(0).Rows(ab)(5)
dr(6) = ds.Tables(0).Rows(ab)(6)
dr(7) = ds.Tables(0).Rows(ab)(7)
dr(8) = ds.Tables(0).Rows(ab)(8)
dr(9) = ds.Tables(0).Rows(ab)(9)
dstoo.Tables(0).Rows.Add(dr) 'add the new rows to the table
Next
dgSec.DataSource = dstoo
dgSec.DataMember = dstoo.Tables(0).TableName
dgSec.Refresh()
MsgBox("continue?") 'just to be able to look at the datagrid
If dstoo.HasChanges Then
Try
sqlDa.Update(dstoo, dstoo.Tables(0).TableName)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
dstoo.AcceptChanges() 'make all changes permanent
dgMain.DataSource = dstoo
dgMain.DataMember = dstoo.Tables(0).TableName
sqlDa.Fill(ds, "Sites") 'connect the dataset to the table
dgSec.DataSource = ds
dgSec.DataMember = "Sites" 'check the table for new data
con.Close()
MsgBox("Ready") 'finished
End Sub
and this is the message I get on the line
"sqlDa.Update(dstoo,dstoo.Tables(0).TableName)"
System.Data.SqlClient.SqlException: Line 1: wrong syntaxis at ].
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at MDBtoSDF.Form1.btConvert_Click(Object sender, EventArgs e) in
D:\VB.NET projecten\PPC\MDBtoSDF\Form1.vb:line 264
I don't have a clue what it all means...
rg,
Eric
Could you please take a look and tell me what this means?
Cor has tried to help me, but we haven't found it yet.
Everytime I run this code, I get an exception error.
Here is my code:
Dim connStr As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=" &
Me.txtFile.Text
Dim SQLstr As String = "SELECT * FROM sitelist"
Dim cn As New OleDb.OleDbConnection(connStr)
Dim da As New OleDb.OleDbDataAdapter(SQLstr, cn)
Dim ds As New DataSet
pgBar.Value = 0
pgBar.Refresh()
da.Fill(ds, "sitelist")
pgBar.Value += 1
pgBar.Refresh()
dgMain.DataSource = ds
dgMain.DataMember = "Sitelist"
dgMain.Refresh()
cn.Close()
'FileNaam = FileNaam.Replace("sitelijst.mdb", "sitelist.mdf")
Dim con As New SqlConnection("Server=(local);database=;Integrated
Security=SSPI")
Dim cmd1 As New SqlCommand("DROP DATABASE sitelist", con)
con.Open()
Try
cmd1.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Dim strSQL As String = "CREATE DATABASE sitelist"
Dim cmd2 As New SqlCommand(strSQL, con)
Try
cmd2.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
cmd2.CommandText = "USE sitelist " & vbCrLf & _
"CREATE TABLE sites (sitenummer NVARCHAR(10), " & _
"adres NVARCHAR(255), gemeente NVARCHAR(25), " & _
"[Type site] NVARCHAR(25), bsc NVARCHAR(35), " & _
"Safety NVARCHAR(25), [X pos] NVARCHAR(15), " & _
"[Y pos] NVARCHAR(15), verantwoordelijke NVARCHAR(25), " & _
"online NVARCHAR(15), CONSTRAINT [pk_indentFT] PRIMARY " & _
"KEY CLUSTERED(sitenummer))"
Try
cmd2.ExecuteNonQuery()
Catch ex As Exception
'do nothing
End Try
con.Close()
Dim sqlNewstr As String
con = New SqlConnection("Server=(local);Database=sitelist;Integrated
Security=SSPI;")
Dim sqlDa = New SqlDataAdapter
sqlDa.SelectCommand = New SqlCommand("SELECT * FROM sites", con)
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(sqlDa)
cb.QuoteSuffix = "["
cb.QuotePrefix = "]"
Dim dstoo As New DataSet
sqlDa.Fill(dstoo, "Sites") 'connect the dataset to the empty table
Dim ab As Integer
Dim dr As DataRow
For ab = 0 To ds.Tables(0).Rows.Count - 1
dr = dstoo.Tables(0).NewRow()
dr(0) = ds.Tables(0).Rows(ab)(0)
dr(1) = ds.Tables(0).Rows(ab)(1)
dr(2) = ds.Tables(0).Rows(ab)(2)
dr(3) = ds.Tables(0).Rows(ab)(3)
dr(4) = ds.Tables(0).Rows(ab)(4)
dr(5) = ds.Tables(0).Rows(ab)(5)
dr(6) = ds.Tables(0).Rows(ab)(6)
dr(7) = ds.Tables(0).Rows(ab)(7)
dr(8) = ds.Tables(0).Rows(ab)(8)
dr(9) = ds.Tables(0).Rows(ab)(9)
dstoo.Tables(0).Rows.Add(dr) 'add the new rows to the table
Next
dgSec.DataSource = dstoo
dgSec.DataMember = dstoo.Tables(0).TableName
dgSec.Refresh()
MsgBox("continue?") 'just to be able to look at the datagrid
If dstoo.HasChanges Then
Try
sqlDa.Update(dstoo, dstoo.Tables(0).TableName)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If
dstoo.AcceptChanges() 'make all changes permanent
dgMain.DataSource = dstoo
dgMain.DataMember = dstoo.Tables(0).TableName
sqlDa.Fill(ds, "Sites") 'connect the dataset to the table
dgSec.DataSource = ds
dgSec.DataMember = "Sites" 'check the table for new data
con.Close()
MsgBox("Ready") 'finished
End Sub
and this is the message I get on the line
"sqlDa.Update(dstoo,dstoo.Tables(0).TableName)"
System.Data.SqlClient.SqlException: Line 1: wrong syntaxis at ].
at
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at MDBtoSDF.Form1.btConvert_Click(Object sender, EventArgs e) in
D:\VB.NET projecten\PPC\MDBtoSDF\Form1.vb:line 264
I don't have a clue what it all means...
rg,
Eric