473,397 Members | 1,949 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,397 software developers and data experts.

Error when creating dataReader

I have:

par1 = New SqlParameter("@mediaId", SqlDbType.VarChar, 10)
par1.Value = "text"
myParams.Add(par1)

par2 = New SqlParameter("@datumStart", SqlDbType.DateTime)
par2.Value = Now()
myParams.Add(par2)

sql = "c_returnTimeSlotsHour"
Dim rdr As SqlDataReader
rdr = funkcije.createDataReader(sql, False, myParams)

Then I have my function:

Function createDataReader(ByVal sqlStr As String, Optional ByVal type As
Boolean = False, Optional ByVal myParams As Collection = Nothing) As
SqlDataReader
Dim oCmd As SqlCommand
Dim myReader As SqlDataReader
Dim param As SqlParameter
oCmd = New SqlCommand(sqlStr, createConnection)
If type = False Then
oCmd.CommandType = CommandType.StoredProcedure
If Not myParams Is Nothing Then
For Each param In myParams
oCmd.Parameters.Add(param)
Next
End If
End If
myReader = oCmd.ExecuteReader(CommandBehavior.CloseConnection )
Return myReader
End Function

The procedure:

CREATE PROCEDURE c_returnTimeSlotsHour
@mediaId as varchar(10),
@datumStart as datetime
AS

SELECT ....

When I run this, I always get an error message:

Syntax error converting the varchar value 'text' to a column of data type
int.

Why?

Thank you,
Simon
Nov 18 '05 #1
1 1390
I have to guess that the problem is with the SELECT statement in your
stored procedure. My guess is that the parameter @mediaId, which
contains the value "text", is being compared to a column that is
defined as an INT data type. Check your SELECT statement and make
sure the data types match up.

-KIRBY
--
Kirby Turner, MCSD, MCAD
www.whitepeaksoftware.com
On Tue, 14 Sep 2004 16:57:29 +0200, "simon"
<si*********@stud-moderna.si> wrote:
I have:

par1 = New SqlParameter("@mediaId", SqlDbType.VarChar, 10)
par1.Value = "text"
myParams.Add(par1)

par2 = New SqlParameter("@datumStart", SqlDbType.DateTime)
par2.Value = Now()
myParams.Add(par2)

sql = "c_returnTimeSlotsHour"
Dim rdr As SqlDataReader
rdr = funkcije.createDataReader(sql, False, myParams)

Then I have my function:

Function createDataReader(ByVal sqlStr As String, Optional ByVal type As
Boolean = False, Optional ByVal myParams As Collection = Nothing) As
SqlDataReader
Dim oCmd As SqlCommand
Dim myReader As SqlDataReader
Dim param As SqlParameter
oCmd = New SqlCommand(sqlStr, createConnection)
If type = False Then
oCmd.CommandType = CommandType.StoredProcedure
If Not myParams Is Nothing Then
For Each param In myParams
oCmd.Parameters.Add(param)
Next
End If
End If
myReader = oCmd.ExecuteReader(CommandBehavior.CloseConnection )
Return myReader
End Function

The procedure:

CREATE PROCEDURE c_returnTimeSlotsHour
@mediaId as varchar(10),
@datumStart as datetime
AS

SELECT ....

When I run this, I always get an error message:

Syntax error converting the varchar value 'text' to a column of data type
int.

Why?

Thank you,
Simon


Nov 18 '05 #2

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

Similar topics

3
by: Dave Bailey | last post by:
When I execute the following code on a WebForm I get the following message: Object reference not set to an instance of an object. This error occurs at the dataConnection.ConnectionString...
6
by: karim | last post by:
I have an asp.net page that stopped running properly giving the error below. The app uses a SQL Server 2000 on another server. Enterprise Manager and Query analyzer on the web server can connect to...
4
by: Troy | last post by:
We recently installed the .Net framework on a windows 2000 server. Shortly after that we experienced intermitant problems running a web based program that accesses an Access 2002 database. The...
0
by: Vilmar Brazão de Oliveira | last post by:
Hi, I am having err when creating link to each line of grid at LINE 38. My objective in asp.net is: each line can be linked to page with your parameters as VB 5/6, Delphi 5/6/7, etc.... See the...
4
by: James Radke | last post by:
Hello, I am looking for guidance on best practices to incorporate effective and complete error handling in an application written in VB.NET. If I have the following function in a class module...
21
by: Carolyn | last post by:
I've got a program that collects info from an Access. I'm trying to use the following select command to select all the information from the "Families" table and store it in a dataset, plus join...
6
by: Ben | last post by:
I am trying to migrate my vb6.0 over to vb.net. Here is the error that that I am stuck with: Public myDB As DAO.Database ..... path = System.IO.Path.GetFullPath("..") myDB =...
3
by: Garth Wells | last post by:
used the following "classic ASP" approach to build a dynamic menu, but would like to know the proper way to implement the same functionality using a .Net technique (e.g., placing the code in the...
3
by: Johnny Jörgensen | last post by:
I've got an error that I simply cannot locate: I've got a form in which I use a datareader object to read information from a db. After the read, I close the reader and I dispose of both the...
1
by: Allan Ebdrup | last post by:
I have a web application (ASP.Net V2) that fetches stuff from the database. I've created a test project in Visual Studio 2005. In the webtest I fetch data from some webservices that query the...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.