Hey.. I have a form consisting of datagridview and two buttons of update and load all.. I have used fillby method to obtain data from database. The query seems to be working fine, except that the data is not shown in the gridview.
As in, for the qeury, if the returned rows are 2, it will show 3 rows in the gridview, but all empty.
Here is my code.. Please help me !!
Vb.net and Ms Access 2003 -
-
Imports System.Data
-
Imports System.Data.OleDb
-
Imports System.EventArgs
-
Imports System.Data.OleDb.OleDbConnection
-
Imports System.Data.OleDb.OleDbCommand
-
-
Public Class Form1
-
Inherits System.Windows.Forms.Form
-
-
Dim wrkdir As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly.Location())
-
Dim da As New OleDbDataAdapter
-
Dim ds As New DataSet
-
Dim bs As New BindingSource
-
Dim edit As Boolean
-
'Dim cnn As OleDbConnection
-
-
-
Dim cnn As New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
-
-
'cnn = New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
-
'cnn.Open()
-
-
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
-
-
If edit Then
-
da.Update(ds, "partno")
-
edit = False
-
End If
-
-
End Sub
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
'TODO: This line of code loads data into the 'HemDatabase1DataSet.partno' table. You can move, or remove it, as needed.
-
Me.PartnoTableAdapter.Fill(Me.HemDatabase1DataSet.partno)
-
-
dgv1.DataSource = bs
-
-
'Dim cnn As New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
-
'cnn = New OleDbConnection("Provider=microsoft.jet.oledb.4.0;Data Source=E:\Project-Hemtech\HemDatabase1.mdb;")
-
'cnn.Open()
-
-
End Sub
-
-
Private Sub button2_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
-
-
ds.Tables.Clear()
-
-
If tsText.Text <> "" Then
-
-
Dim sql As String = "SELECT partno.partnum, partno.partname, partno.partdesc, partno.partqty " & _
-
"FROM(partno)" & _
-
"WHERE (((partno.type)='" & tsText.Text & "'));"
-
-
Dim cmd As New OleDbCommand(sql, cnn)
-
-
da.SelectCommand = cmd
-
-
Dim cmdBuilder As New OleDbCommandBuilder(da)
-
-
da.Fill(ds, "partno")
-
bs.DataSource = ds.Tables(0)
-
-
Else
-
-
Exit Sub
-
-
End If
-
End Sub
-
-
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As EventArgs) Handles button3.Click
-
-
ds.Tables.Clear()
-
-
Dim sql As String = "SELECT * FROM partno;"
-
Dim cmd As New OleDbCommand(sql, cnn)
-
-
da.SelectCommand = cmd
-
-
Dim cmdbuilder As New OleDbCommandBuilder(da)
-
da.Fill(ds, "partno")
-
bs.DataSource = ds.Tables(0)
-
-
End Sub
-
-
Private Sub FillByToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
-
Try
-
Me.PartnoTableAdapter.FillBy(Me.HemDatabase1DataSet.partno, tsText.Text)
-
Catch ex As System.Exception
-
System.Windows.Forms.MessageBox.Show(ex.Message)
-
End Try
-
-
End Sub
-
End Class
-
-
0 1415 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: T.Haugnes |
last post by:
I've installed visual studio c# express, .net SDK 2.0, SQL Server
Express, created a table in the SQL database and filled this with some
data-rows. I dragged the database-table from Data...
|
by: thomasp |
last post by:
This is a two part question,
1) The code below should display a form with a datagridview and a few
command buttons. This form should allow the user to make change to the
records displayed
in...
|
by: TNSFED |
last post by:
I have a dilemma when trying to delete a row from the DataGridView. Here
is a sample of my code:
private void dgv_EQUPS_UserDeletingRow(object sender,
DataGridViewRowCancelEventArgs e)
{...
|
by: schoultzy |
last post by:
Hello Everyone,
I have been trying to figure this one out for two days now. I have
created a DataGridView which is populated by an ObjectDataSource. My
problem occurs when I attempt to use the...
|
by: Steve Richter |
last post by:
what is the best way to use DataGridView to view data from large
database tables? Where the sql select statement might return millions
of rows?
string connectionString =...
| |
by: snowdog17 |
last post by:
Hello,
I am a student and I need help with my VB task. I am currently using VB 2005 Express and I am fairly new to it, although I have programed in Delphi before....
|
by: TG |
last post by:
Hi!
I have an application in which I have some checkboxes and depending
which ones are checked those columns will show in the datagridview
from sql server or no.
After that I have 2 buttons:...
|
by: Andrus |
last post by:
I have Winforms DataGridView whose DataSource Rids is Marc sample
TableListCollection<TRowderived from BindingList.
It is used to edit invoice rows.
If user presses Revert button, my application...
|
by: Andrus |
last post by:
I have DataGridView in virtual mode containing 3500 rows.
In code below, assigning to RowCount value to 3500 takes 8 seconds.
CPU usage goes high at this time.
Stepping by F11 into user code shows...
|
by: BRawn |
last post by:
Hi guys,
I'm struggling to copy rows from one DataGridView to another. This may sound redundant but it's necessary for my Orders project. I have 3 DataGridViews on one form.
The first...
|
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...
| |
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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,...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |