473,698 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble displaying info from access db

Hi Everyone,

I have the project below where I'm pulling out information from 1 table
"Subjects", pulling the Subjects, and SubjectCode. The Subjects are
displaying in the Combo Box just fine, but I can not get the
corresponding Subject Code to display in the Label.

I have 2 Data adapters/dataset,1 for Subjects, and the other for
SubjectCode, along with a Data View setup.

I'm a newbie on VB.NET. This project is pulling from an Access DB. Is
there anything that I should be looking for, or doing wrong that I'm
not getting the Subject Code to display in the Label?

Any help would be appreciated.
_______________ _______________ ____
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Fill the List box
dbSubject.Fill( DsSubject1)
dbSubjectCode.F ill(DsSubjectCo de2)
DisplayRecordPo sition()
End Sub

Private Sub cboSubjectName_ SelectedIndexCh anged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
cboSubjectName. SelectedIndexCh anged
' DsSubject1.Clea r()
' dbSubject.Selec tCommand.Parame ters("Subjects" ).Value =
cboSubjectName. Text
' dbSubjectCode.F ill(DsSubjectCo de2)
End Sub

Private Sub lblSubName_Clic k(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles lblSubName.Clic k
DsSubjectCode2. Clear()
dbSubjectCode.S electCommand.Pa rameters("Subje ctCode").Value =
lblSubName.Text
dbSubjectCode.F ill(DsSubjectCo de2)

End Sub
'*****General Procedures*****
Private Sub DisplayRecordPo sition()
Dim intRecordCount As Integer
Dim intRecordPositi on As Integer

intRecordCount = DsSubject1.Tabl es("Subjects"). Rows.Count

If intRecordCount = 0 Then
lblSubName.Text = "(No records)"
Else
intRecordPositi on = Me.BindingConte xt(DsSubject1,
"Subjects").Pos ition + 1
lblSubName.Text = "Record: " & intRecordPositi on.ToString _
& " of " & intRecordCount. ToString
End If
End Sub
End Class
_______________ _______________ _______________ ________

Nov 20 '06 #1
3 1175
The first question is, do you need a DataAdapter? Are you going to update,
insert or delete data? If so, then yes a DA is the way to go. If you are
just reading, use a DataReader. Much faster.

1.Fill Data Reader & Bind to Drop Down List (SQL Example)
'Populate Drop Down List
Dim coReader As SqlClient.SqlDa taReader

'SQL Server Connection Object From Form - You would replace with your Access
Connection object
conSQL.Open()

'SQL Server Command Object From Form - You would replace with an Access
command object
cmdSQL.CommandT ext = "SELECT Subject, SubjectCode FROM <<TABLE>ORDER BY
Subject"

coReader = cmdSQL.ExecuteR eader()
ddlSubject.Data Source = coReader
ddlSubject.Data TextField = "Subject"
ddlSubject.Data ValueField = "SubjectCod e"
ddlSubject.Data Bind()
coReader.Close( )
conSQL.Close()

2.On SelectedIndexCh ange of Combo Box, set Label Value
lblSubCode.Text = CTYPE(ddlSubjec ts.SelectedValu e, String)

This will give you a drop down populated with subjects and then when you
select one, the code of that subject will be displayed in the label.

"GeekyChick y79" <sk******@aol.c omwrote in message
news:11******** *************@j 44g2000cwa.goog legroups.com...
Hi Everyone,

I have the project below where I'm pulling out information from 1 table
"Subjects", pulling the Subjects, and SubjectCode. The Subjects are
displaying in the Combo Box just fine, but I can not get the
corresponding Subject Code to display in the Label.

I have 2 Data adapters/dataset,1 for Subjects, and the other for
SubjectCode, along with a Data View setup.

I'm a newbie on VB.NET. This project is pulling from an Access DB. Is
there anything that I should be looking for, or doing wrong that I'm
not getting the Subject Code to display in the Label?

Any help would be appreciated.
_______________ _______________ ____
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Fill the List box
dbSubject.Fill( DsSubject1)
dbSubjectCode.F ill(DsSubjectCo de2)
DisplayRecordPo sition()
End Sub

Private Sub cboSubjectName_ SelectedIndexCh anged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
cboSubjectName. SelectedIndexCh anged
' DsSubject1.Clea r()
' dbSubject.Selec tCommand.Parame ters("Subjects" ).Value =
cboSubjectName. Text
' dbSubjectCode.F ill(DsSubjectCo de2)
End Sub

Private Sub lblSubName_Clic k(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles lblSubName.Clic k
DsSubjectCode2. Clear()
dbSubjectCode.S electCommand.Pa rameters("Subje ctCode").Value =
lblSubName.Text
dbSubjectCode.F ill(DsSubjectCo de2)

End Sub
'*****General Procedures*****
Private Sub DisplayRecordPo sition()
Dim intRecordCount As Integer
Dim intRecordPositi on As Integer

intRecordCount = DsSubject1.Tabl es("Subjects"). Rows.Count

If intRecordCount = 0 Then
lblSubName.Text = "(No records)"
Else
intRecordPositi on = Me.BindingConte xt(DsSubject1,
"Subjects").Pos ition + 1
lblSubName.Text = "Record: " & intRecordPositi on.ToString _
& " of " & intRecordCount. ToString
End If
End Sub
End Class
_______________ _______________ _______________ ________

Nov 20 '06 #2
Frankly I don't think I do...but then again I'm new at all of this. All
I'm doing is pulling the information from the Access DB.

DB Name: Subjects
Table1: Subject (Drop down box)
Table2: SubjectCode (Listbox)

Just trying to figure out why the Label isn't displaying the
information. All I'm getting is the Record 1 of 12 displaying in that
Label, and not the "SubjectCod e"

If you had the program and click on the Combo Box in the Design View,
in the properties window where you have Data Source...it's pulling the
information for the Subject that way. And in the Form1_Load, it
pulls/displays the information only for the Combo Box.

Any thoughts?

Nov 20 '06 #3
Are you talking about a Label control that is on the form?
Where is "Record 1 of 12" showing up? Sounds like the text
in a Binding Navigator. Are you setting that?

Robin S.
-----------------------------
"GeekyChick y79" <sk******@aol.c omwrote in message
news:11******** **************@ e3g2000cwe.goog legroups.com...
Frankly I don't think I do...but then again I'm new at all of this. All
I'm doing is pulling the information from the Access DB.

DB Name: Subjects
Table1: Subject (Drop down box)
Table2: SubjectCode (Listbox)

Just trying to figure out why the Label isn't displaying the
information. All I'm getting is the Record 1 of 12 displaying in that
Label, and not the "SubjectCod e"

If you had the program and click on the Combo Box in the Design View,
in the properties window where you have Data Source...it's pulling the
information for the Subject that way. And in the Form1_Load, it
pulls/displays the information only for the Combo Box.

Any thoughts?

Nov 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4963
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my webserver runs that part of the script (see attached file, snippet.php), though, it doesn't go through. I don't get an error message or anything...it just returns a "1" (whereas it should return a "0") as far as I can tell. I have read the PHP...
2
1371
by: Rose | last post by:
Hi all, I'm a newbie to C# and .NET, so please be gentle! My limited background is in VBScript,ASP, and Access dbs. I need to retrieve data from a SQL server db (8.0) to be displayed in a table format on a web page. I also need to do some major calculations with the numbers from the DB, and insert them into the table. ie, if (field = something) then display a row of calculated values.
0
1287
by: James Dean | last post by:
I have trouble displaying a bitmap. I have 1bpp information. I also have a command telling me what color i need to set the bytes to when the colour is switched on. The trouble is i do all this but it will not display properly. I convert this to 8bpp information. I set the relevant pixel to for example "255,0,0" for Red.....is this right?....i set the Red byte to 255 and the other two values set to 0. I think the Bitmap data class i am...
7
3382
by: Terry | last post by:
I have a Mainform with a Statusbar. When opening another form or doing some processing I want to display info in the Statusbar of the Mainform. I have read a lot of articles on this & have come up with the code below. It seems to work(!!!) in that when coding the second form I can see the DisplayStatusMsg of the main form. During debug the code runs through & seemingly executes the call without error. But!...The message is not displayed....
1
1296
by: Flack | last post by:
Hey guys, Here is the scenario: I have the main form open and a background thread is running. The background thread sometimes needs access to the main forms graphics object and gets it by calling Graphics g = CreateGraphics(). Now, I close my main form while the background thread is running and when the background thread gets to the CreateGraphics() line, it throws an
3
1514
by: raj chahal | last post by:
Hi there I've created a db field with Memo type, and I have stored some text with carriage returns (no html) So the 3 words start on a differnt line. In access this displays correctly ( each word starts on a new line). However when I display these on a web page all the words appear on the same line. I need the words to be displayed on a seperate line.
10
5754
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the images) of the gridview come from a single table/datasource. Here is my situation. In my web application, I need to display customer bills info in a gridview. Customer names and contact info are from the Customer table.
1
1654
by: Jeremy.Campbell | last post by:
I am trying to add a picture to a form that is visible depending on certain criteria. The picture works perfectly on my computer, but on other users computers this image is either black or scrambled. Can someone please help!??!?
10
1824
by: Clamato | last post by:
Good Morning, I'm working with a form that basically add's a users windows logon ID, first name, and last name to a table. A list box on this form is then requeried once added displaying the names in this table. I'm ultimately trying to make it so the user can't add their information twice in this table. Well, you would think just making their ID the PK in the table would work, however I'm running into an issue with this. The user...
0
8674
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9028
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...
1
8895
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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...
1
6518
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
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3046
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
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.