473,662 Members | 2,593 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(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
UpdateDataGrid( "SELECT * FROM Main")
End Sub


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


Private Sub btnRefresh_Clic k(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnRefresh.Clic k
dgDisplay.Dispo se()
UpdateDataGrid( "SELECT * FROM Main")
End Sub


Sub UpdateDataGrid( ByVal sqlStr As String)
Dim dt As New DataTable
Dim connStr As String = "provider=micro soft.jet.oledb. 4.0;" & "data source = PriManagement.m db"
Dim dataAdapter As New OleDb.OleDbData Adapter(sqlStr, connStr)
[COLOR=DarkRed]dataAdapter.Fil l(dt)[/COLOR] this is where i get my error :confused:
dataAdapter.Dis pose()
dgDisplay.DataS ource = dt
End Sub
Attached Images
File Type: jpg Untitled-1.jpg (38.2 KB, 196 views)
Oct 16 '05 #1
1 1496
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
2378
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 field... This grid displayes results based on users search.. public static int numberDiv; private void Page_Load(object sender, System.EventArgs e) {
9
1708
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 system since all this data will be stored in memory. The performance is really affected with this. Since we don't really want to redesign everything based on this datatable, are there any companies that offer a product similar to the datatable...
0
6427
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 be modified: if(e.CommandName =="Print") { string parsedreceipt = null; parsedreceipt = DecodeReceipt (e.Item.Cells.Text); Session = parsedreceipt;
2
2580
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 OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _ "ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Inetpub\wwwroot\DataG" & _ "rid Test\E-Logbook.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global...
2
6948
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 attending interviews. If you own a company best way to judge if the candidate is worth of it. http://www.questpond.com/InterviewRatingSheet.zip
3
1723
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 which has a DataGrid, slap the DataSet onto the DataGrid, and set the form.visible to true. I'm having trouble with a very early part of the process. The first
0
3659
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 delegates were given CDs containing a pre-release version of the .NET framework/SDK and Visual Studio.NET. · When was the first version of .NET released? The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on...
0
3832
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 for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. · What are user controls and custom controls? Custom controls: A control authored by a user or a third-party software vendor that...
2
1661
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 following circumstances: Datagrid populated with 1 record then re-populated with all Datagrid populated with 1 record then re-populated with another single record Datagrid populated with multiple records and displaying page 1 then
0
8344
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7367
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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 we have to send another system

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.