473,769 Members | 5,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with queries. Call for help.

I am having a problem with queries running in this code When I use the
query "SELECT * FROM sample" the code runs and the data grid binds and shows
the contents of the sample table. If I change the query to filter the
results such as "SELECT * FROM sample WHERE (sales 2000)" the code fails
on - objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection) with an unknown
error.
If I load the database up into access2000 and run the sql queries they run
as expected so I know they are valid queries of the data

I am a noob at asp.net data. Can anybody give me a hand?

The Code I am using is below followed by the error info with the stack
trace.

-----------------------------------------------------------------------------

Imports System.Data.Ole Db
Imports System.Data

Sub btnRunQuery_OnC lick(ByVal Sender As Object, ByVal E As EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String

objConnection = New
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; Data Source=" &
Server.MapPath( "NewDatabase.md b") & ";")

strSQLQuery = "SELECT * FROM sample"

'strSQLQuery = "SELECT * FROM sample WHERE (sales 2000)"

'strSQLQuery = "SELECT * FROM sample WHERE key_id=5"

'strSQLQuery = "SELECT * FROM sample WHERE last_name='John son'"

objCommand = New OleDbCommand(st rSQLQuery, objConnection)

objConnection.O pen()

objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

lblSQLCommandLa bel.Text = strSQLQuery

EmployeeDataGri d.DataSource = objDataReader
EmployeeDataGri d.DataBind()
End Sub
-------------------------------------------------------------

Unknown
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: Unknown

Source Error:
Line 61: objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
Stack Trace:

[OleDbException (0x80040e14): Unknown]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr)
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior,
Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior behavior)
Database101.Web Form1.btnRunQue ry_OnClick(Obje ct Sender, EventArgs E) in
c:\Database101\ WebForm1.aspx.v b:61
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.370 5.6060; ASP.NET
Version:1.0.370 5.6060
Jan 18 '08 #1
2 1538
What is the data type (int, decimal , string, text) of "sales" ?

"johnmay124 8" <jo*********@be llsouth.netwrot e in message
news:z8******** ***********@big news5.bellsouth .net...
>I am having a problem with queries running in this code When I use the
query "SELECT * FROM sample" the code runs and the data grid binds and
shows
the contents of the sample table. If I change the query to filter the
results such as "SELECT * FROM sample WHERE (sales 2000)" the code fails
on - objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection) with an unknown
error.
If I load the database up into access2000 and run the sql queries they run
as expected so I know they are valid queries of the data

I am a noob at asp.net data. Can anybody give me a hand?

The Code I am using is below followed by the error info with the stack
trace.

-----------------------------------------------------------------------------

Imports System.Data.Ole Db
Imports System.Data

Sub btnRunQuery_OnC lick(ByVal Sender As Object, ByVal E As EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String

objConnection = New
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; Data Source=" &
Server.MapPath( "NewDatabase.md b") & ";")

strSQLQuery = "SELECT * FROM sample"

'strSQLQuery = "SELECT * FROM sample WHERE (sales 2000)"

'strSQLQuery = "SELECT * FROM sample WHERE key_id=5"

'strSQLQuery = "SELECT * FROM sample WHERE last_name='John son'"

objCommand = New OleDbCommand(st rSQLQuery, objConnection)

objConnection.O pen()

objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

lblSQLCommandLa bel.Text = strSQLQuery

EmployeeDataGri d.DataSource = objDataReader
EmployeeDataGri d.DataBind()
End Sub
-------------------------------------------------------------

Unknown
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: Unknown

Source Error:
Line 61: objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
Stack Trace:

[OleDbException (0x80040e14): Unknown]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr)

System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior,
Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior behavior)
Database101.Web Form1.btnRunQue ry_OnClick(Obje ct Sender, EventArgs E) in
c:\Database101\ WebForm1.aspx.v b:61
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.370 5.6060;
ASP.NET
Version:1.0.370 5.6060


Jan 18 '08 #2
Try using a parameterized query instead of inline SQL statement. Its best
practices technique anyway.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"johnmay124 8" wrote:
I am having a problem with queries running in this code When I use the
query "SELECT * FROM sample" the code runs and the data grid binds and shows
the contents of the sample table. If I change the query to filter the
results such as "SELECT * FROM sample WHERE (sales 2000)" the code fails
on - objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection) with an unknown
error.
If I load the database up into access2000 and run the sql queries they run
as expected so I know they are valid queries of the data

I am a noob at asp.net data. Can anybody give me a hand?

The Code I am using is below followed by the error info with the stack
trace.

-----------------------------------------------------------------------------

Imports System.Data.Ole Db
Imports System.Data

Sub btnRunQuery_OnC lick(ByVal Sender As Object, ByVal E As EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader
Dim strSQLQuery As String

objConnection = New
OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0; Data Source=" &
Server.MapPath( "NewDatabase.md b") & ";")

strSQLQuery = "SELECT * FROM sample"

'strSQLQuery = "SELECT * FROM sample WHERE (sales 2000)"

'strSQLQuery = "SELECT * FROM sample WHERE key_id=5"

'strSQLQuery = "SELECT * FROM sample WHERE last_name='John son'"

objCommand = New OleDbCommand(st rSQLQuery, objConnection)

objConnection.O pen()

objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

lblSQLCommandLa bel.Text = strSQLQuery

EmployeeDataGri d.DataSource = objDataReader
EmployeeDataGri d.DataBind()
End Sub
-------------------------------------------------------------

Unknown
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.Ole Db.OleDbExcepti on: Unknown

Source Error:
Line 61: objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)
Stack Trace:

[OleDbException (0x80040e14): Unknown]
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextErrorHandli ng(Int32 hr)
System.Data.Ole Db.OleDbCommand .ExecuteCommand TextForSingleRe sult(tagDBPARAM S
dbParams, Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand Text(Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r behavior,
Object& executeResult)
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior behavior)
Database101.Web Form1.btnRunQue ry_OnClick(Obje ct Sender, EventArgs E) in
c:\Database101\ WebForm1.aspx.v b:61
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e)
System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain()


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.370 5.6060; ASP.NET
Version:1.0.370 5.6060
Jan 19 '08 #3

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

Similar topics

2
1745
by: justme | last post by:
Dears I have created the following page to display my data <head> <style type="text/css"> body, td, th, h1, h2 {font-family: sans-serif;} body, td, th {font-size: 100%;} a:link { font-weight:bold; color:E00000; text-decoration:none } a:visited { font-weight:bold; color:E00000; text-decoration:none } a:hover { font-weight:bold; color:#E00000; text-decoration:none }
9
2823
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
10
2139
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post shouldn't be here). I have two design questions: 1. what is the correct (or best) way to include database queries into the code if you plan on
1
4755
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I have a page in a folder (under anonymous authentication in IIS6) that has a link on it that...
1
2099
by: loosecannon_1 | last post by:
Hello everyone, I am hoping someone can help me with this problem. I will say up front that I am not a SQL Server DBA, I am a developer. I have an application that sends about 25 simultaneous queries to a SQL Server 2000 Standard Edition SP4 running on Windows 2000 Server with 2.5 GB of memory. About 11 of these queries are over views (all over the same table) and these queries are all done from JDBC but I am not sure that matters. ...
3
1321
by: coder | last post by:
I am new to programming in PHP however, this should be a pretty straight forward answer. I have three queries that I am pulling for a content form page. 1) The Author List 2) The Content Page (pulls the PK, Title and the Description of the content. 3) The Category List When I attempt to pull the data the only result set I get back is from
9
5759
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just call it Express for simplicity). I have, to try to simplify things, put the exact same DB on two systems, one running MSDE and one running Express. Both have 2 Ghz processors (one Intel, one AMD), both have a decent amount of RAM (Intel system...
12
3067
by: JHNielson | last post by:
I have a simple question, but I can't seem to find the answer. I have this code to count the number of records that pass through a set of processes: It counts how many records go through INPUT, VALIDATED, ERRORS This is the code to get the numbers: Function Val_Message()
1
15218
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they can no longer connect to the domain controller. Ping resolves the domain controllers name to the correct ip nslookup finds the ip but can not resolve the name. When I attempt to log on to a machine on the domain it takes around twenty minutes...
0
9590
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
9424
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
10051
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...
0
9866
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...
0
8879
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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
6675
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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.