Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
param.Direction = ParameterDirection.Output;
return param;
}
and I get:
Cannot implicitly convert type 'int' to 'System.Data.SqlClient.SqlParameter'
problem is that I dont "want" to be needed to specify datatype of the
parameter, if I check "6 of 6" in that yellow hint-box, as I get it, I'm
able to just pass the parameter-name.
or what's needed to do?
TIA
/Lasse 5 6378
Richard,
I cant pass the value since that's what im trying to retrieve.
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... The problem is you are calling the following overload of Add
int Add( object o );
and you are trying to assign it to a SqlParameter reference - hence the
error message. if you can supply the value as well you can call this overload
SqlParameter Add(string name, object value);
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uq**************@TK2MSFTNGP14.phx.gbl> Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
param.Direction = ParameterDirection.Output;
return param;
} and I get:
Cannot implicitly convert type 'int' to
'System.Data.SqlClient.SqlParameter'
problem is that I dont "want" to be needed to specify datatype of the parameter, if I check "6 of 6" in that yellow hint-box, as I get it, I'm able to just pass the parameter-name.
or what's needed to do?
TIA /Lasse
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 [microsoft.public.dotnet.languages.csharp]
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = new SqlParameter();
param.ParameterName = sqlParam;
param.Direction = ParameterDirection.Output;
cmd.Parameters.Add(param);
return param;
}
Sijin Joseph http://www.indiangeek.net http://weblogs.asp.net/sjoseph
Lasse Edsvik wrote: Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
param.Direction = ParameterDirection.Output;
return param;
} and I get:
Cannot implicitly convert type 'int' to 'System.Data.SqlClient.SqlParameter' problem is that I dont "want" to be needed to specify datatype of the parameter, if I check "6 of 6" in that yellow hint-box, as I get it, I'm able to just pass the parameter-name.
or what's needed to do?
TIA /Lasse
OK in that case you'll need to change your code as follows:
SqlParameter GetParameter(SqlCommand cmd, string pname)
{
SqlParameter p = new SqlParameter();
p.ParameterName = pname;
p.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p);
return p;
}
btw: when are you doing to set the param type for the out param?
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<eq**************@TK2MSFTNGP09.phx.gbl>
Richard,
I cant pass the value since that's what im trying to retrieve.
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl... The problem is you are calling the following overload of Add
int Add( object o );
and you are trying to assign it to a SqlParameter reference - hence the
error message. if you can supply the value as well you can call this overload
SqlParameter Add(string name, object value);
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uq**************@TK2MSFTNGP14.phx.gbl> Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
param.Direction = ParameterDirection.Output;
return param;
} and I get:
Cannot implicitly convert type 'int' to
'System.Data.SqlClient.SqlParameter'
problem is that I dont "want" to be needed to specify datatype of the parameter, if I check "6 of 6" in that yellow hint-box, as I get it, I'm able to just pass the parameter-name.
or what's needed to do?
TIA /Lasse
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 [microsoft.public.dotnet.languages.csharp]
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004
[microsoft.public.dotnet.languages.csharp]
Richard,
hmm, not sure, what happens if i dont?
btw, do i "need" to pass the "SqlCommand cmd"?
thx
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl... OK in that case you'll need to change your code as follows:
SqlParameter GetParameter(SqlCommand cmd, string pname) { SqlParameter p = new SqlParameter(); p.ParameterName = pname; p.Direction = ParameterDirection.Output; cmd.Parameters.Add(p); return p; }
btw: when are you doing to set the param type for the out param?
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<eq**************@TK2MSFTNGP09.phx.gbl> Richard,
I cant pass the value since that's what im trying to retrieve.
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... > The problem is you are calling the following overload of Add > > int Add( object o ); > > and you are trying to assign it to a SqlParameter reference - hence the error message. > > if you can supply the value as well you can call this overload > > SqlParameter Add(string name, object value); > > Regards > > Richard Blewett - DevelopMentor > http://staff.develop.com/richardb/weblog > >
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uq**************@TK2MSFTNGP14.phx.gbl> > > Hello > > I have this: > > public SqlParameter GetParameter(string sqlparam) > > { > > > SqlParameter param = cmd.Parameters.Add(sqlparam); > > param.Direction = ParameterDirection.Output; > > return param; > > } > > > > and I get: > > Cannot implicitly convert type 'int' to 'System.Data.SqlClient.SqlParameter' > > > > problem is that I dont "want" to be needed to specify datatype of the > parameter, if I check "6 of 6" in that yellow hint-box, as I get it,
I'm > able to just pass the parameter-name. > > or what's needed to do? > > TIA > /Lasse > > > > > > > > > --- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 > > > > [microsoft.public.dotnet.languages.csharp] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004 [microsoft.public.dotnet.languages.csharp]
SqlParameter defaults its SqlDbType to NVarChar. So unless you are only going to return NVarChar types and you preset the size, this isn't going to work.
Also, if you don't pass the SqlCommand in how are you going to call cmd.Parameters.Add, do you have it as a member variable?
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<#Y**************@TK2MSFTNGP10.phx.gbl>
Richard,
hmm, not sure, what happens if i dont?
btw, do i "need" to pass the "SqlCommand cmd"?
thx
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl... OK in that case you'll need to change your code as follows:
SqlParameter GetParameter(SqlCommand cmd, string pname) { SqlParameter p = new SqlParameter(); p.ParameterName = pname; p.Direction = ParameterDirection.Output; cmd.Parameters.Add(p); return p; }
btw: when are you doing to set the param type for the out param?
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<eq**************@TK2MSFTNGP09.phx.gbl> Richard,
I cant pass the value since that's what im trying to retrieve.
/Lasse
"Richard Blewett [DevelopMentor]" <ri******@develop.com> wrote in message news:%2***************@tk2msftngp13.phx.gbl... The problem is you are calling the following overload of Add
int Add( object o );
and you are trying to assign it to a SqlParameter reference - hence the error message. if you can supply the value as well you can call this overload
SqlParameter Add(string name, object value);
Regards
Richard Blewett - DevelopMentor http://staff.develop.com/richardb/weblog
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<uq**************@TK2MSFTNGP14.phx.gbl> Hello
I have this:
public SqlParameter GetParameter(string sqlparam)
{
SqlParameter param = cmd.Parameters.Add(sqlparam);
param.Direction = ParameterDirection.Output;
return param;
} and I get:
Cannot implicitly convert type 'int' to
'System.Data.SqlClient.SqlParameter'
problem is that I dont "want" to be needed to specify datatype of the parameter, if I check "6 of 6" in that yellow hint-box, as I get it,
I'm able to just pass the parameter-name.
or what's needed to do?
TIA /Lasse
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 [microsoft.public.dotnet.languages.csharp]
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004 [microsoft.public.dotnet.languages.csharp]
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 24/09/2004
[microsoft.public.dotnet.languages.csharp] This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan |
last post by:
I've run into an interesting problem, and seemed to have stumped 3
newsgroups and 2 other forums.
For some reason when I try to insert a record into a SQL table that has a
Text column, the...
|
by: WGW |
last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost!
everything I need. Maybe not efficiently, but usefully. However, I have
a problem -- a complex query problem...
I can...
|
by: wkaras |
last post by:
I would like to propose the following changes to the C++ Standard,
the goal of which are to provide an improved ability to specify
the constraints on type parameters to templates. Let me say from...
|
by: Siegfried Weiss |
last post by:
Hi guys,
i give up finding a solution by reading or by trial & error. Hope, YOU
can help me! (Sorry for my rather long posting.)
Stroustrup says, that templates could be declared with
- type...
|
by: Dave Veeneman |
last post by:
Can I pass a method pass one of its out parameters to another method? C# is
telling me I can't.
Let's say I have two methods, FooManager and FooWorker. FooManager is part
of a class that acts as...
|
by: Billie Boy |
last post by:
Hi to all.
I’m new here and am coming to you from Melbourne Australia.
So a big
HELLO 2 ALL.
Now I am encountering an annoying problem in the SQL builder of the copy of VB.6 that I am using at...
|
by: Alec MacLean |
last post by:
Hi,
I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in).
Background: I'm creating a survey system for our company, for...
|
by: =?Utf-8?B?QmlsbEF0V29yaw==?= |
last post by:
Hi,
We recently converted a 1.1 project to 2.0 and this included a webservice
which accepted XML for one of the parameters. Since converting to 2.0 I am
getting the following message:
---
A...
|
by: Trevisc |
last post by:
Happy Thursday Everyone,
I am trying to create a parameter that is one long varchar but that
will be used in a SQL statement IN function:
//string queryString = GetCurrentTitles();
//Below is...
|
by: DanicaDear |
last post by:
I have something interesting...looking to see if anyone else has came across this.
I have a query with parameter and and the query works beautifully every time. However, when I use the wizard...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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,...
| |