Speed in VB 2005

  • Thread starter Stephen Plotnick
  • Start date
S

Stephen Plotnick

I upgraded from VB 2003 to VB 2005.

I have a 4000 record table in Access that I'm using oleDB to do a data
adapter fill to a Data Grid. In VB.2003 it takes 2-3 seconds to load the
data grid in vb 2005 it takes aroudn 20 seconds. IS there something that
could be causing this problem?
 
C

Cor Ligthert [MVP]

Stephen,
IS there something that could be causing this problem?

Yes a lot, but in most cases (not all) VBNet is faster.

Can you show a piece of your code that does the fill of the datagrid?
(only VBNet although I am curious how you use that datagrid in VB6)


Cor
 
G

GhostInAK

Hello Cor Ligthert [MVP],

*pokes* Cor, There was no VB6 mentioned. I know 2003 was a long time ago..

-Boo
 
K

Ken Halter

GhostInAK said:
Hello Cor Ligthert [MVP],

*pokes* Cor, There was no VB6 mentioned. I know 2003 was a long time
ago..

-Boo

fwiw, I'd like to see any dotNet code run faster than a fully compiled and
optimized VB6 version of that same code. Heck... I'd like to see a dotNet
IDE that starts up in less time than it takes to make a cup of coffee. Oh
well... Quad core CPUs are coming out soon. Maybe then we'll see 386 era
performance from a dotNet app.
 
C

Cor Ligthert [MVP]

Stephen,

Sorry for my misunderstanding.
Are you using exactly the same code, because this is the first time I read
about your problem.

Cor
 
S

Stephen Plotnick

All I did was install the VB 2005 and copy the source ccode from the VB.NET
(2003)

Private Sub PopulateStoreGrid()

Dim conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
source=C:\BMActivityReporting.mdb;Persist Security Info=False")

Dim sSQL As String

If Mid(UserNoLink, 1, 1) = "0" Or Mid(UserNoLink, 1, 1) = "9" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE"

End If

If Mid(UserNoLink, 1, 1) = "1" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE BDRNo LIKE '" &
Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "2" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE RDSNo LIKE '" &
Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "3" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE MSNo LIKE '" &
Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "4" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE SDSNo LIKE '" &
Mid(UserNoLink, 1, 4) & "'"

End If

Dim sSQL2 As String = "select * from BENMOORETABLE"

conn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter(sSQL, conn)

Dim da2 As New System.Data.OleDb.OleDbDataAdapter(sSQL2, conn)

Try

da.Fill(myDS, "BENMOOR1")

iCount = myDS.Tables("BENMOOR1").Rows.Count

da2.Fill(myDS, "BENMOOR2")

myDV = myDS.Tables("BENMOOR2").DefaultView

DataGrid1.DataSource = myDS

DataGrid1.DataMember = "BENMOOR1"

Dim irow As Integer

Dim icol As Integer

irow = 0

DataGrid1.Select(irow)

Dim sStore As String = CType(DataGrid1.Item(irow, 1), String)

myDV.Sort = "STORE_NUMBER"

Dim rowIndex As Integer = myDV.Find(sStore)

Me.LegalName1.Text = myDV(rowIndex)("LEGAL_NAME_LINE1").ToString()

Me.LegalName2.Text = myDV(rowIndex)("LEGAL_NAME_LINE2").ToString()

Me.StoreOwner.Text = myDV(rowIndex)("STORE_OWNER").ToString()

Me.PhoneNumber.Text = myDV(rowIndex)("PHONE_NUMBER").ToString()

Me.LegalName3.Text = myDV(rowIndex)("LEGAL_NAME_LINE3").ToString()

Me.LegalName4.Text = myDV(rowIndex)("LEGAL_NAME_LINE4").ToString()

Me.EMailAddress.Text = myDV(rowIndex)("E-MAIL_ADDRESS").ToString()

Fil_Name()

'UpdateScreen(irow)

Catch ex As Exception

MessageBox.Show("Failed to connect to data source")

Finally

conn.Close()

End Try

End Sub



Steve
 
C

Cor Ligthert [MVP]

Stephen,

I don't know why it is,

I made this Test program
\\\
'Set in advance a reference to COM adox ext 2.x for dll and security

Public Class Main
Public Shared Sub Main()
'cleanup old databases
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\db1.mdb")

Dim conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE tester ( " & _
"Id int ," & _
"Whatever NVarchar(50)," & _
"CONSTRAINT [pk_Id] PRIMARY KEY (Id)) ", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter("Select * from tester", conn)
da.Fill(ds)
For i As Integer = 0 To 40000
ds.Tables(0).LoadDataRow(New Object() {i, i.ToString}, False)
Next
Dim cmb As New OleDb.OleDbCommandBuilder(da)
da.Update(ds)
Dim ds2 As New DataSet
Dim start As Integer = Environment.TickCount
da.Fill(ds2)
MessageBox.Show((Environment.TickCount - start).ToString)
End Sub
End Class
///

The result is that the Fill part is about 7 times slower in VB2005 than in
VB2003

I will put this problem as well in another place.

It does not help you but you know that I had the same result.

Cor
 
S

Stephen Plotnick

Cor,

Thanks for the quick program and test. I'll need to go back to using vb.NET
for now until this can get resolved; what are the procedures for finding out
when this gets fixed?

Steve
Cor Ligthert said:
Stephen,

I don't know why it is,

I made this Test program
\\\
'Set in advance a reference to COM adox ext 2.x for dll and security

Public Class Main
Public Shared Sub Main()
'cleanup old databases
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\db1.mdb")

Dim conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE tester ( " & _
"Id int ," & _
"Whatever NVarchar(50)," & _
"CONSTRAINT [pk_Id] PRIMARY KEY (Id)) ", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter("Select * from tester", conn)
da.Fill(ds)
For i As Integer = 0 To 40000
ds.Tables(0).LoadDataRow(New Object() {i, i.ToString}, False)
Next
Dim cmb As New OleDb.OleDbCommandBuilder(da)
da.Update(ds)
Dim ds2 As New DataSet
Dim start As Integer = Environment.TickCount
da.Fill(ds2)
MessageBox.Show((Environment.TickCount - start).ToString)
End Sub
End Class
///

The result is that the Fill part is about 7 times slower in VB2005 than in
VB2003

I will put this problem as well in another place.

It does not help you but you know that I had the same result.

Cor


Stephen Plotnick said:
All I did was install the VB 2005 and copy the source ccode from the
VB.NET (2003)

Private Sub PopulateStoreGrid()

Dim conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
source=C:\BMActivityReporting.mdb;Persist Security Info=False")

Dim sSQL As String

If Mid(UserNoLink, 1, 1) = "0" Or Mid(UserNoLink, 1, 1) = "9" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE"

End If

If Mid(UserNoLink, 1, 1) = "1" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE BDRNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "2" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE RDSNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "3" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE MSNo LIKE '"
& Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "4" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE SDSNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

Dim sSQL2 As String = "select * from BENMOORETABLE"

conn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter(sSQL, conn)

Dim da2 As New System.Data.OleDb.OleDbDataAdapter(sSQL2, conn)

Try

da.Fill(myDS, "BENMOOR1")

iCount = myDS.Tables("BENMOOR1").Rows.Count

da2.Fill(myDS, "BENMOOR2")

myDV = myDS.Tables("BENMOOR2").DefaultView

DataGrid1.DataSource = myDS

DataGrid1.DataMember = "BENMOOR1"

Dim irow As Integer

Dim icol As Integer

irow = 0

DataGrid1.Select(irow)

Dim sStore As String = CType(DataGrid1.Item(irow, 1), String)

myDV.Sort = "STORE_NUMBER"

Dim rowIndex As Integer = myDV.Find(sStore)

Me.LegalName1.Text = myDV(rowIndex)("LEGAL_NAME_LINE1").ToString()

Me.LegalName2.Text = myDV(rowIndex)("LEGAL_NAME_LINE2").ToString()

Me.StoreOwner.Text = myDV(rowIndex)("STORE_OWNER").ToString()

Me.PhoneNumber.Text = myDV(rowIndex)("PHONE_NUMBER").ToString()

Me.LegalName3.Text = myDV(rowIndex)("LEGAL_NAME_LINE3").ToString()

Me.LegalName4.Text = myDV(rowIndex)("LEGAL_NAME_LINE4").ToString()

Me.EMailAddress.Text = myDV(rowIndex)("E-MAIL_ADDRESS").ToString()

Fil_Name()

'UpdateScreen(irow)

Catch ex As Exception

MessageBox.Show("Failed to connect to data source")

Finally

conn.Close()

End Try

End Sub



Steve
 
P

Paul Clement

¤ I upgraded from VB 2003 to VB 2005.
¤
¤ I have a 4000 record table in Access that I'm using oleDB to do a data
¤ adapter fill to a Data Grid. In VB.2003 it takes 2-3 seconds to load the
¤ data grid in vb 2005 it takes aroudn 20 seconds. IS there something that
¤ could be causing this problem?
¤

Aren't you using some type of paging mechanism for the DataGrid. Querying for and loading 4,000 rows
at one time is really not a very good idea.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
C

Cor Ligthert [MVP]

Stephen,

I don't know if the method with the datareader will help you.

http://msdn2.microsoft.com/en-us/library/system.data.datatable.load.aspx

I did not test that.

Cor

Stephen Plotnick said:
Cor,

Thanks for the quick program and test. I'll need to go back to using
vb.NET for now until this can get resolved; what are the procedures for
finding out when this gets fixed?

Steve
Cor Ligthert said:
Stephen,

I don't know why it is,

I made this Test program
\\\
'Set in advance a reference to COM adox ext 2.x for dll and security

Public Class Main
Public Shared Sub Main()
'cleanup old databases
Dim catNewDB As New ADOX.Catalog
Dim fi As New IO.FileInfo("c:\db1.mdb")
If fi.Exists Then
If MessageBox.Show("Delete?", "Existing File db1.mdb", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
fi.Delete()
Else
Exit Sub
End If
End If
catNewDB.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & "Data
Source=C:\db1.mdb")

Dim conn As New
OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
" Data Source=C:\db1.mdb;User Id=admin;Password=;")
Dim cmd As New OleDb.OleDbCommand("CREATE TABLE tester ( " & _
"Id int ," & _
"Whatever NVarchar(50)," & _
"CONSTRAINT [pk_Id] PRIMARY KEY (Id)) ", conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter("Select * from tester", conn)
da.Fill(ds)
For i As Integer = 0 To 40000
ds.Tables(0).LoadDataRow(New Object() {i, i.ToString}, False)
Next
Dim cmb As New OleDb.OleDbCommandBuilder(da)
da.Update(ds)
Dim ds2 As New DataSet
Dim start As Integer = Environment.TickCount
da.Fill(ds2)
MessageBox.Show((Environment.TickCount - start).ToString)
End Sub
End Class
///

The result is that the Fill part is about 7 times slower in VB2005 than
in VB2003

I will put this problem as well in another place.

It does not help you but you know that I had the same result.

Cor


Stephen Plotnick said:
All I did was install the VB 2005 and copy the source ccode from the
VB.NET (2003)

Private Sub PopulateStoreGrid()

Dim conn As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
source=C:\BMActivityReporting.mdb;Persist Security Info=False")

Dim sSQL As String

If Mid(UserNoLink, 1, 1) = "0" Or Mid(UserNoLink, 1, 1) = "9" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE"

End If

If Mid(UserNoLink, 1, 1) = "1" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE BDRNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "2" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE RDSNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "3" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE MSNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

If Mid(UserNoLink, 1, 1) = "4" Then

sSQL = "select BM_NUMBER, STORE_NUMBER, STORE, SHIP_ADDRESS1 as ADDRESS,
SHIP_CITY as CITY, SHIP_ST as STATE from BENMOORETABLE WHERE SDSNo LIKE
'" & Mid(UserNoLink, 1, 4) & "'"

End If

Dim sSQL2 As String = "select * from BENMOORETABLE"

conn.Open()

Dim da As New System.Data.OleDb.OleDbDataAdapter(sSQL, conn)

Dim da2 As New System.Data.OleDb.OleDbDataAdapter(sSQL2, conn)

Try

da.Fill(myDS, "BENMOOR1")

iCount = myDS.Tables("BENMOOR1").Rows.Count

da2.Fill(myDS, "BENMOOR2")

myDV = myDS.Tables("BENMOOR2").DefaultView

DataGrid1.DataSource = myDS

DataGrid1.DataMember = "BENMOOR1"

Dim irow As Integer

Dim icol As Integer

irow = 0

DataGrid1.Select(irow)

Dim sStore As String = CType(DataGrid1.Item(irow, 1), String)

myDV.Sort = "STORE_NUMBER"

Dim rowIndex As Integer = myDV.Find(sStore)

Me.LegalName1.Text = myDV(rowIndex)("LEGAL_NAME_LINE1").ToString()

Me.LegalName2.Text = myDV(rowIndex)("LEGAL_NAME_LINE2").ToString()

Me.StoreOwner.Text = myDV(rowIndex)("STORE_OWNER").ToString()

Me.PhoneNumber.Text = myDV(rowIndex)("PHONE_NUMBER").ToString()

Me.LegalName3.Text = myDV(rowIndex)("LEGAL_NAME_LINE3").ToString()

Me.LegalName4.Text = myDV(rowIndex)("LEGAL_NAME_LINE4").ToString()

Me.EMailAddress.Text = myDV(rowIndex)("E-MAIL_ADDRESS").ToString()

Fil_Name()

'UpdateScreen(irow)

Catch ex As Exception

MessageBox.Show("Failed to connect to data source")

Finally

conn.Close()

End Try

End Sub



Steve

Stephen,

Sorry for my misunderstanding.
Are you using exactly the same code, because this is the first time I
read about your problem.

Cor

"Cor Ligthert [MVP]" <[email protected]> schreef in bericht
Stephen,

IS there something that could be causing this problem?

Yes a lot, but in most cases (not all) VBNet is faster.

Can you show a piece of your code that does the fill of the datagrid?
(only VBNet although I am curious how you use that datagrid in VB6)


Cor

"Stephen Plotnick" <[email protected]> schreef in bericht
I upgraded from VB 2003 to VB 2005.

I have a 4000 record table in Access that I'm using oleDB to do a
data adapter fill to a Data Grid. In VB.2003 it takes 2-3 seconds to
load the data grid in vb 2005 it takes aroudn 20 seconds. IS there
something that could be causing this problem?
 
J

Jeff

Ken Halter said:
"GhostInAK" <[email protected]> wrote in message
fwiw, I'd like to see any dotNet code run faster than a fully compiled and
optimized VB6 version of that same code. Heck... I'd like to see a dotNet
IDE that starts up in less time than it takes to make a cup of coffee. Oh
well... Quad core CPUs are coming out soon. Maybe then we'll see 386 era
performance from a dotNet app.


I'm having a hard time trying to figure out if you like .net or not Ken...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top