473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error when creating data reader

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 21 '05 #1
0 917

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

Similar topics

9
3059
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
21
1792
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...
1
1463
by: zoneal | last post by:
pls let me know where i am going wrong. Dim categories As ArrayList Private Sub LoadCategoryDropDownList() Dim sCat As String For Each sCat In categories ///pls see the error at the bottom of...
3
2379
by: Doug Durrett | last post by:
I'm having an issue and wanted to pass it by everyone to see what you think. Here is my code. //Code Start searchs = new...
3
1199
by: ankitdave | last post by:
Hi Guyz.. I am working on the creating a web service and I have a code like Public function test (byval query as string) as string query.loadxml (queryxml)
5
3131
by: Pucca | last post by:
I'm gettting this error at "Application.Run" in the code below. The error message also says "Out of Memory". How can I find out more about what's causing this error? It just breaks there with no...
13
2819
by: lithoman | last post by:
I'm stumped here. I run the procedure Batch_Select against the database with @ID=18 and I get the expected data. When it loads into a SqlDataReader, it gets messed up somehow. Initially, after the...
1
2746
by: weird0 | last post by:
I have created a GridView and dynamically added data to it by creating a DataTable(as advised) and bound it with a reader. Then, assigned the DataSource of GridView to DataTable. But even that aint...
2
3559
by: =?Utf-8?B?U2ltb24uVUs=?= | last post by:
Hi, I've created an appplication using the SQL XML Bulk Load COM object. When i run the application in debug it works as expected and also when i run the setup project the application is in on...
0
7260
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
7384
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,...
1
7099
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...
0
5685
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,...
1
5086
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...
0
3233
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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 ...
0
456
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...

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.