473,781 Members | 2,280 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble executing SP, SqlDbType.Bit.. .

ASP.NET 2.0

This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong

This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessa ge @id uniqueidentifie r, @user int, @type
bit

Here is the ASP.NET code
public override void DeleteMessage(S ystem.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(t his.ConnectionS tring))
{
SqlCommand cmd = new SqlCommand("Sen dMessage", cn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("@id", SqlDbType.Uniqu eIdentifier).Va lue = id;
cmd.Parameters. Add("@user", SqlDbType.Int). Value = user;
cmd.Parameters. Add("@type", SqlDbType.Bit). Value = type;
}
}

any suggetions?

Jeff
Apr 16 '07 #1
1 6185
It says boolean, so you need to pass true (with no quotation marks) or false
-- for the value.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Jeff" wrote:
ASP.NET 2.0

This stored procedure fails because the variable type contains a number.
I've debugged the SP in VS2005 and it works if I change the 0/1 value of
type to true/false... How should I fix this?? I cannot just replace type
with the phrase "false" or "true"... maybe using SqlDbType.Bit is wrong

This is header of this SP:
ALTER PROCEDURE dbo.DeleteMessa ge @id uniqueidentifie r, @user int, @type
bit

Here is the ASP.NET code
public override void DeleteMessage(S ystem.Guid id, int user, Boolean type)
{
using (SqlConnection cn = new SqlConnection(t his.ConnectionS tring))
{
SqlCommand cmd = new SqlCommand("Sen dMessage", cn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Parameters. Add("@id", SqlDbType.Uniqu eIdentifier).Va lue = id;
cmd.Parameters. Add("@user", SqlDbType.Int). Value = user;
cmd.Parameters. Add("@type", SqlDbType.Bit). Value = type;
}
}

any suggetions?

Jeff
Apr 16 '07 #2

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

Similar topics

10
3400
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void AddMinimunWageStipen(string payrollid,double amount) { System.Data.SqlClient.SqlConnection cn = null; System.Data.SqlClient.SqlCommand cm = null;
1
13297
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through the application's front end the file appears to be corrupt. The front-end application has a way of inserting files to the column, however when I analyze this in SQL Profiler the contents of the Byte array appear to be quite different than the one...
9
6310
by: Jerome | last post by:
Hi, I keep getting the same compiler error: 'Name 'SqlDbType' is not declared' and I don't know why? I've declared the following: <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %> <%@ import Namespace="System.Data." %>
0
1091
by: simon | last post by:
I have dataGrid on my page with edit button. When user click edit button and change some value and after that click update button, the following code is executed: oCmd = New SqlCommand("c_MediaType", funkcije.createConnection) oCmd.CommandType = CommandType.StoredProcedure oCmd.Parameters.Add("@mediaId", SqlDbType.VarChar, 10).Value = dgdMediaType.DataKeys.Item(e.Item.ItemIndex) oCmd.Parameters.Add("@aktiven", SqlDbType.Bit).Value =...
5
1443
by: mlg1906 | last post by:
I'm developing an intranet site in ASP.NET 2.0 but I can't seem to connect to the DB from within my code. I've created a .vb class that houses a private Connection() that other functions within the class can call to connect to the database. In the calling function, I've declared my connection object and called the "Open" method on the object. However, when I attempt to execute the stored procedure command by calling the "ExecuteScalar"...
3
1340
by: Peter Newman | last post by:
In running vb.net 2003 and am trying to run a stored procedure Dim InputString() As String InputString = Split(InputParm, ";") ' set the query commands STR_SQLCOMMAND.CommandText = "BossData.dbo.OperatorLogon" STR_SQLCOMMAND.CommandType = CommandType.StoredProcedure STR_SQLCOMMAND.CommandTimeout = 30
4
29398
by: Chris Bordeman | last post by:
I have a DataColumn, want to derive the DbType. I can do column.GetType() but that's a system type, not a db type. How do I convert it to the corresponding type? Thanks much! Chris B.
2
1418
by: rcoco | last post by:
I'm having an error message sounding like : Prepared statement '(@id text)SELECT * from isp_email.staff where @id like +txtname.' expects parameter @id, which was not supplied. This message appear when I press button to select a row at run time. What could be the problem? SqlCommand myCommand = new SqlCommand(); myCommand.Connection=con; myCommand.CommandText="SELECT * from isp_email.staff where @id like +txtname.Text";
4
2992
by: jleeie | last post by:
Can someone help me, I'm going round in circles with this and my head is cabbaged ! I am using visual studio 2005 & VB & MS SQL 2005 I am trying to execute a stored procedure from within a program. I want to return values. I can get a 0 or 1 returned. I don't seem to be able to get any other value returned. below is my VB code and the stored procedure. I would really appreciate if someone would have a look that knows how to do this....
0
9636
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
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10139
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
9931
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
8961
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...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
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.