473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Display data

37
Hi there,
I need to get values from Access database and bind it to ThresholdLabel. I could not use the drag and drop method because i want the data to be displayed during button click event, not when the form loads. I have a field called AC250L from Threshold Database. So how do i go about doing that?
Jul 16 '07 #1
9 1659
hariharanmca
1,977 1GB
Hi there,
I need to get values from Access database and bind it to ThresholdLabel. I could not use the drag and drop method because i want the data to be displayed during button click event, not when the form loads. I have a field called AC250L from Threshold Database. So how do i go about doing that?

Is it possible to explain your problem in point by point..
Jul 16 '07 #2
tigger
37
Is it possible to explain your problem in point by point..
Hey sorry for not making myself clear. My main aim is to select a name from the combo box and when i click a button(getButton), it will display the threshold value for that particular person. I've managed to display the values on a label. Here's my code..

Imports System.Data
Imports System.Data.OleDb
Imports System.IO

Public Class DatabaseProject


Private Sub DatabaseProject_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Actual_DatabaseDataSet.Threshold_Database' table. You can move, or remove it, as needed.
Me.Threshold_DatabaseTableAdapter.Fill(Me.Actual_D atabaseDataSet.Threshold_Database)

End Sub

Private Sub getButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getButton.Click, AC250LLabel1.Click

Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim cmd As OleDb.OleDbCommand

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\BIE\Actual Database.mdb;Jet OLEDB:Database Password=****"
sql = "SELECT * FROM ThresholdDatabase"

con.Open()

cmd = New OleDb.OleDbCommand(sql, con)
Dim dataAdapter As New OleDb.OleDbDataAdapter(cmd)
dataAdapter.Fill(ds, "YourTableName")

Me.NameComboBox.DataSource = ds.Tables("Threshold Database")

da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Actual_Database")

con.Close()

thresholdLabel.Text = ds.Tables("Actual_Database").Rows(6).Item("AC250L" ) & "dB"

End Sub

End Class


However, when i display the data, i have to manually type which row and which item i want to retrieve it from. I don't know how to link it to my combo box. Thanks.
Jul 17 '07 #3
hariharanmca
1,977 1GB
Hey sorry for not making myself clear. My main aim is to select a name from the combo box and when i click a button(getButton), it will display the threshold value for that particular person. I've managed to display the values on a label. Here's my code..

Imports System.Data
Imports System.Data.OleDb
Imports System.IO

Public Class DatabaseProject


Private Sub DatabaseProject_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Actual_DatabaseDataSet.Threshold_Database' table. You can move, or remove it, as needed.
Me.Threshold_DatabaseTableAdapter.Fill(Me.Actual_D atabaseDataSet.Threshold_Database)

End Sub

Private Sub getButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles getButton.Click, AC250LLabel1.Click

Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim cmd As OleDb.OleDbCommand

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\BIE\Actual Database.mdb;Jet OLEDB:Database Password=****"
sql = "SELECT * FROM ThresholdDatabase"

con.Open()

cmd = New OleDb.OleDbCommand(sql, con)
Dim dataAdapter As New OleDb.OleDbDataAdapter(cmd)
dataAdapter.Fill(ds, "YourTableName")

Me.NameComboBox.DataSource = ds.Tables("Threshold Database")

da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Actual_Database")

con.Close()

thresholdLabel.Text = ds.Tables("Actual_Database").Rows(6).Item("AC250L" ) & "dB"

End Sub

End Class


However, when i display the data, i have to manually type which row and which item i want to retrieve it from. I don't know how to link it to my combo box. Thanks.

I am not sure that you mean this. Let me assume

You want to select a particular name in combo box text area

so

Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM ThresholdDatabase" 
just change this qry to


Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM ThresholdDatabase where AC250L like ‘" & trim(ComboboxName.Text) & “’”

and

Expand|Select|Wrap|Line Numbers
  1. thresholdLabel.Text = ds.Tables("Actual_Database").Rows(0).Item("AC250L") & "dB"
Jul 17 '07 #4
tigger
37
I am not sure that you mean this. Let me assume

You want to select a particular name in combo box text area

so

Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM ThresholdDatabase" 
just change this qry to


Expand|Select|Wrap|Line Numbers
  1. sql = "SELECT * FROM ThresholdDatabase where AC250L like ‘" & trim(ComboboxName.Text) & “’”

and

Expand|Select|Wrap|Line Numbers
  1. thresholdLabel.Text = ds.Tables("Actual_Database").Rows(0).Item("AC250L") & "dB"
Hey thanks for the reply. I tried putting in the query but it seems to have an error.
da.Fill(ds, "Actual_Database") is highlighted and it says "Syntax error in FROM clause."
Jul 19 '07 #5
hariharanmca
1,977 1GB
Hey thanks for the reply. I tried putting in the query but it seems to have an error.
da.Fill(ds, "Actual_Database") is highlighted and it says "Syntax error in FROM clause."

ThresholdDatabase is a table name?

because, the select Qurey will be like

Expand|Select|Wrap|Line Numbers
  1. select <field1>, <field2>, <field3>, <field4> from <Table Name> where <Condition>
Jul 19 '07 #6
tigger
37
ThresholdDatabase is a table name?

because, the select Qurey will be like

Expand|Select|Wrap|Line Numbers
  1. select <field1>, <field2>, <field3>, <field4> from <Table Name> where <Condition>
I've already managed to solve the problem. Thanks. But i faced another problem. Each time i select a name in the combo box, it will appear twice and the previous name disappears. For example, i select John and click a button to display a value. When i go back to the combo box and want to select another name, i realized that John's name will appear twice. And the name before John will disappear.
Jul 20 '07 #7
hariharanmca
1,977 1GB
I've already managed to solve the problem. Thanks. But i faced another problem. Each time i select a name in the combo box, it will appear twice and the previous name disappears. For example, i select John and click a button to display a value. When i go back to the combo box and want to select another name, i realized that John's name will appear twice. And the name before John will disappear.
I think the problem is with Load event of combo box. (if no problem, you can post it and let me Look-over to solve).
Jul 20 '07 #8
tigger
37
I think the problem is with Load event of combo box. (if no problem, you can post it and let me Look-over to solve).
I don't face the problem anymore. Thanks a lot for your help. Appreciate it =)
Jul 23 '07 #9
Killer42
8,435 Expert 8TB
I don't face the problem anymore. Thanks a lot for your help. Appreciate it =)
Could you fill us in briefly on how you resolved it? This could be useful if someone else comes along with the same problem. (Don't worry if it's something silly - we've all been there.)
Jul 23 '07 #10

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

Similar topics

3
by: StepH | last post by:
Hi, I'm building a little application, which the goal is to: 1./ Collect data via Serial line and or via a file (for playback). 2./ Display these data as graph, oscilloscope, ... How manage...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
2
by: Kay | last post by:
This function is used to display the context of a queue. I input an integer comparing with the queue cuisine number, if cuisine number is same as the input, it shows the context. However, it cannot...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
7
by: Stefan Finzel | last post by:
Hi, is there a way to change the display property on Windows Mobile 2003 SE Mobile/Pocket Internet Explorer? See following example. Please note: visibilty property has the same problem. Is...
1
by: JK | last post by:
In my win form, I'm trying to display a Crystal report with the data in my dataset only but, if I follow the steps in this msdn page: ...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: Eric Keung | last post by:
Hi all, my case is I want to get an image from access database and I just know it's "OLE object" field type at access I also don't know how to insert it into access here is my code and it just...
1
by: John Phelan-Cummings | last post by:
When I add the name of a new individual in a, bound form, it will not display that person’s name in a label control of a second unbound form. I have a scheduling program that I am working on. ...
18
by: Terry Holland | last post by:
I have an asp.net (1.1) application that connects to a SQL server 2000 db. I have a stored procedure in my db that out puts data in xml format. What I need to be able to do is display that xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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 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.