473,508 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET: display data on datagrid gives error

1 New Member
i'm very new to SQL Server and VB.Net 2003

i'm trying to display data on a DataGrid and it's keeps given me an error

this is the code i'm using and i hope someone can help


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
UpdateDataGrid("SELECT * FROM Main")
End Sub


Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
UpdateDataGrid("SELECT * FROM Main")
End Sub


Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
dgDisplay.Dispose()
UpdateDataGrid("SELECT * FROM Main")
End Sub


Sub UpdateDataGrid(ByVal sqlStr As String)
Dim dt As New DataTable
Dim connStr As String = "provider=microsoft.jet.oledb.4.0;" & "data source = PriManagement.mdb"
Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
[COLOR=DarkRed]dataAdapter.Fill(dt)[/COLOR] this is where i get my error :confused:
dataAdapter.Dispose()
dgDisplay.DataSource = dt
End Sub
Attached Images
File Type: jpg Untitled-1.jpg (38.2 KB, 195 views)
Oct 16 '05 #1
1 1486
nateraaaa
663 Recognized Expert Contributor
Try the following code found on MSDN

Expand|Select|Wrap|Line Numbers
  1. [Visual Basic] 
  2. Public Function SelectOleDbSrvRows(dataSet As DataSet, connection As String, query As String) As DataSet
  3.     Dim conn As New OleDbConnection(connection)
  4.     Dim adapter As New OleDbDataAdapter()
  5.     adapter.SelectCommand = new OleDbCommand(query, conn)
  6.     adapter.Fill(dataset)
  7.     Return dataset
  8. End Function
  9.  
Dec 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
2365
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
9
1700
by: VMI | last post by:
We have this huge application that's based on storing tons of data on a dataTable. The only problem we're having is that storing LOTS of data (1 million records) into a datatable will slow down the...
0
6414
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
2
2578
by: Start28 | last post by:
I'm trying to get some data to display in a datagrd on an ASP.net page The only thing It displaus is the header here are somr snoppets of the code: Me.OleDbConnection1.ConnectionString = "Jet...
2
6926
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
3
1714
by: sherifffruitfly | last post by:
Hi all, I've got a class with a private DataSet member, and a void display() method. The display() method is *supposed* to take the DataSet for the class (instance), new up a predefined for...
0
3635
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
3821
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested...
2
1648
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all Got a weird problem with pagination on a datagrid in asp.net 1.1. It's populated depending on user selected criteria (it either displays all or 1 record). It works fine in the...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7495
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.