Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old May 4th, 2005, 07:40 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I made a few changes to your function. This is how I'd do it:

Function MAINquery(ByVal board As String, ByVal chassis As String, ByVal hDDType As String) As System.Data.DataSet
     Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Documents an"& _
"d Settings\Desktop\FinSample.mdb"
     Dim dbConnection As New System.Data.OleDb.OleDbConnection(connectionString )

     Dim queryString As String = "SELECT [System].* FROM [System] WHERE (([System].[Board] = ?) AND ([System]."& _
"[Chassis] = ?) AND ([System].[HDDType] = ?))"
     Dim dbCommand As New System.Data.OleDb.OleDbCommand
     dbCommand.CommandText = queryString
     dbCommand.Connection = dbConnection

     dbCommand.Parameters.Add("@Board", System.Data.DbType.String).Value = board
     dbCommand.Parameters.Add("@Chassis", System.Data.DbType.String).Value = chassis
     dbCommand.Parameters.Add("@HDDType", System.Data.DbType.String).Value = hDDType

     Dim dataAdapter As New System.Data.OleDb.OleDbDataAdapter
     dataAdapter.SelectCommand = dbCommand
     Dim dataSet As New System.Data.DataSet
     dataAdapter.Fill(dataSet)

     Return dataSet
 End Function

-Peter
Reply With Quote
  #22 (permalink)  
Old May 4th, 2005, 07:42 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Note the name of the parameters is mostly irrelevant in the above case. What's important is the ORDER. They must be added to the parameters collection in the same order they are used in the command text.

-Peter
Reply With Quote
  #23 (permalink)  
Old May 4th, 2005, 07:56 AM
Authorized User
 
Join Date: Apr 2005
Location: , , .
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter and Prashant, thank you guys so much, I honestly don't know what I'd do, you have both helped me to get the query working as perfect as it could.

Thank You.

D

Reply With Quote
  #24 (permalink)  
Old May 4th, 2005, 11:21 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Cochin, , India.
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I create the same table in access the same row and bound it to a datagrid , i am getting the row perfectly,
This leaves me with only one clue,

Your DB Path is:

C:\Documents an"& _
"d Settings\Desktop\FinSample.mdb

But usually the all paths to Desktop I have seen will be something like like
"C:\Documents and Settings\Administrator\Desktop"
Ie, you have the Loggedin user Administrator before the Desktop

I may not be correct, but please do ensure that you are using the same db, because you might be checking the db on your desktop through access, and the program will be working on another. It happens sometimes...

regards
Prashant
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Access Query from ASP arholly Access ASP 0 January 25th, 2008 03:31 PM
Running query... Question... RinoDM SQL Server 2000 2 July 26th, 2007 08:49 AM
Running a Query anukagni Access 3 May 5th, 2006 12:16 AM
running out of field in query building yixchen Access 2 December 19th, 2005 10:19 AM
Running an SQL query in VBA... Augusta Access VBA 3 December 1st, 2004 05:17 AM



All times are GMT -4. The time now is 09:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.