473,770 Members | 7,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB2008/MS Access problems

10 New Member
Greetings,

I have a program setup for which I would like to pull specific data from an Access database I have created. I know the connection to the database is functioning as I can pull mass data to populate a list box. Where I am having trouble is this. I would like to select a name from said list box and have the database return only information based on the name selected. Once I pull this information I would like to then place each item from this data into it's relevant place on the form. I'd rather not do this using a datagrid on the form. This is what I have currently.

*Note, the names being displayed in the list box is a direct match to the primary keys of each row

Expand|Select|Wrap|Line Numbers
  1. Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  2.         Dim selectedchar As String = characterlst.SelectedItem
  3.         Dim dt As New DataTable
  4.  
  5.         con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Tech\My Documents\4e.mdb;"
  6.         con.Open()
  7.         sql = "SELECT * FROM details WHERE [Name]=" & selectedchar
  8.         da = New OleDb.OleDbDataAdapter(sql, con)
  9.         da.Fill(ds, "opening")
  10.         Try
  11.             Form1.Nametxt.Text = ds.Tables("opening").Rows(0).Item(0)
  12.         Catch ex As Exception
  13.             MessageBox.Show(ex.Message & " - " & ex.Source)
  14.         End Try
  15.  
  16.         con.Close()
  17.  
  18.         Me.DialogResult = System.Windows.Forms.DialogResult.OK
  19.         Me.Close()
  20.     End Sub
  21.  
When I run this code it gives me an error saying
"no value given for one or more required parameters vb access"

If I change the select statement to read

"SELECT * FROM details WHERE Primary Key =" & selectedchar
it throws me an error saying the syntax is incorrect

In both instances the error is thrown at line 8.

Any help would be much appreciated.
Sep 24 '08 #1
2 1865
debasisdas
8,127 Recognized Expert Expert
you need to select an item from characterlst before going for the clock event of the button
Sep 25 '08 #2
Montravont
10 New Member
Meant to update this actually. The problem was this.

I was using

characterlst.se lecteditem

when I should have been using

characterlst.te xt

.selecteditem was returning and integer value for the list location of the selected object instead of the actual text of the selection.

combine that with the fact that for the query to function properly it needed to be done as thus

"Select * FROM details Where name=" & "'" & selectedchar & "'"

the proper/working code is as follows

Expand|Select|Wrap|Line Numbers
  1. Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
  2.         Dim selectedchar As String = characterlst.Text
  3.         con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Tech\My Documents\4e.mdb;"
  4.         con.Open()
  5.         sql = "SELECT * FROM details WHERE name='" & selectedchar & "'"
  6.         da = New OleDb.OleDbDataAdapter(sql, con)
  7.         da.Fill(ds, "opening")
  8.         Try
  9.             Form1.Nametxt.Text = ds.Tables("opening").Rows(0).Item(0)
  10.             Form1.Racecmb.SelectedItem = ds.Tables("opening").Rows(0).Item(1)
  11.         Catch ex As Exception
  12.             MessageBox.Show(ex.Message & " - " & ex.Source)
  13.         End Try
  14.  
  15.         con.Close()
  16.         Form1.Enabled = True
  17.         Me.DialogResult = System.Windows.Forms.DialogResult.OK
  18.         Me.Close()
  19.     End Sub
  20.  
Sep 25 '08 #3

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

Similar topics

7
2541
by: Arthur Dent | last post by:
Does anyone know where i can find a decently thorough list of the language changes in VB2008, such as the new If() function? All i can seem to find through search engines, most of the articles all talk about LINQ, with only cursory mention - at best - of any other new features. Thanks in advance, ... Arthur Dent.
2
3443
by: Arthur Dent | last post by:
I am trying to make a VB2008 Express winforms project, and edit the form. However, when i try to open the form, i get this error: ..NET Framework 2.0 update not found. The win32manifest will not be embedded. It considers it a fatal error, and will not let me edit the form, either in code or design view. I have frameworks 1.1, 2.0, 3.5 installed, and all Windows Updates (sans DreamScene).
6
2680
by: Academia | last post by:
I have a computer at home with a (slow) dialup connection and a computer at school with a fast connection. I want to go there (it is not close) and down load Vb2008 express, burn it into a CD, bring it home and install it on my home computer. Someone told me it can't be done. Is there a way of doing that?
8
3216
by: Galen Somerville | last post by:
My graphics involves a lot of line drawings in a short period of time. I have all the graphics in a separate module. I repeatedly get the pixel data from a USB device, draw the requisite traces, get more data, draw traces, etc. The USB appears to take 82 ms between bursts of data. But the drawing is taking 178 ms !!! It's a real time display, like an oscilloscope, whereby I have to blank the
6
4499
by: Scott Gravenhorst | last post by:
Windows XP SP3 My application is set to open a SaveFile dialog when an exit is requested. When I click the app's close button, the save dialog opens, but when I click to change the folder, the exception occurs pointing to FileSaveDialog1.ShowDialog(). The exception also indicates some problem with system.drawing.dll. The exception text is: "Attempted to read or write protected memory. This is often an
9
1195
by: MichaelH | last post by:
Are there any definite advantages of VB2008 over VB2005? Thank in advance. Michael
10
1193
by: Gilbert Tordeur | last post by:
Bonjour. N'y aurait-il pas depuis la VB8 un moyen d'assigner en une seule instruction l'ensemble des propriétés d'un objet aux propriétés de mêmes noms d'un autre objet, plutôt que d'écrire la liste fastidieuse : O2.P1 = O1.P1 O2.P2 = O1.P2 O3.P2 = O1.P3 etc.
2
5796
by: John Whitworth | last post by:
Hi, I'm rewriting an old VB6 app of mine in VB2008. All has been going well with calls to winscard.dll, until I needed to send an array of bytes as part of a structure. When using a winscard trace, I can see that the bytes in the array suddenly become nonsense, whereas I know that what I called the DLL with was good. I think I need to do something along the lines of MarshalAs, but I haven't the first clue where to start. Any...
0
1241
by: John Dann | last post by:
Looking to migrate from VB2005 Pro to VB2008. Can anyone suggest/recommend a VB2008 book that highlights the changes from earlier versions of VB.Net (VB2003/2005) rather than describing VB2008 totally from scratch? I suspect that this may be asking too much in that few books will focus exclusively on migrating/upgrading, but there still may be something out there that is written with existing users of VB.Net in mind. I'm obviously looking...
0
9592
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
9425
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
10058
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
10004
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
9870
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
7416
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
5313
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...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
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.