|
Yeah Chris, you are right. Thanks for pointing out and sorry from my side for the mistake.
Regards
Saanj
Either you love IT or leave IT...
|
|
|
|
|
Dear All,
I have sql query which is
create proc sp_detail
(
@p varchar(max)
)
as
select * from tblName where code in (@p)
I am passing @p from c# application, but it doesent reterieve any data while there is data
cmd=new SqlCommand("sp_detail",p.con);
cmd.CommandType= CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@p",codes);
DataTable dtResult=new DataTable();
if (cmd.Connection.State!=ConnectionState.Open)
cmd.Connection.Open();
dtResult.Load((cmd.ExecuteReader(CommandBehavior.CloseConnection)));
codes is a string which contains codes seperated by comma, as 28-2801,28-2802...
what is wrong here
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
This is a SQL question, really. You're passing the parameter in fine. If you enter your parameter as a variable and run the SQL, does it work then ? Might the issue be your parameter being escaped on the way in ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
the thing is, if i use simpl select statement from c# application every thing works fine as
select * from community where code in ('28-2801','28-2802',...)
but when the store procedure is executed, i got the statement of that from profiler as follows
exec sp_details @p=N'28-2801,28-2802'
while these code exits in database, when i execute this statement from sql, it doesent retrieve a value while if i execute it like this
exec sp_details @p=N'28-2801'
then it returns a rows
with single code it retrieve data, but when passing it seperated by comma nothing is retrieved.
any error there?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
The error seems obvious to me. Passing in your parameter means you specify the whole lot in one set of quotes, when you need to place quotes inside the string. So the value you pass in, needs to have those single quotes around each value, as in
Abdul Rahman Hamidy wrote: '28-2801','28-2802'
and not
Abdul Rahman Hamidy wrote: '28-2801,28-2802'
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
i thought the same as you, but i have done following from sql server, still i am getting no records
<br />
declare @codes varchar(max)<br />
select @codes=cast(quotename('28-2801','''')+','+quotename('28-2802','''') as varchar(max))<br />
print @codes --prints '28-2801','28-2802'<br />
exec [sp_detail] @codes
this doesent work too.
i think first i have to execute the statement in sql server, then i can simply can execute from c#.
in above statement any thing goes worong?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
hmmm.... perhaps there's a reason that I don't know why you can't pass in a string like that. Have you tried string mashing the sql in your proc, or just creating the SQL in code instead of using a proc ?
I think at this point you'd be better asking in the SQL forum ( where this question belonged from the start ), because that's where the SQL heavyweights will be hanging out .
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Asking in the SQL forum would be best
|
|
|
|
|
i'm trying to get a selected range of data from a data set into a new data set,i use an array(dr2) of data rows and from that i get one row at a time and add it to new datatable(dt2), after it is added to a data set.
DataSet ds2 = new DataSet();
DataTable dt2 =new DataTable();
for (int start = startindex ;start < startindex+5 ; start++)
{
DataRow dd = dr2[start];
dt2.ImportRow(dd);
}
ds2.Tables.Add(dt2);
return ds2;
but the problem is when the dataset is returned it has the table with correct no of row, but the rows contain no data, what might be the problem
|
|
|
|
|
sorry to disturb you people , i just found the solution , i missed the clone the table ,
thanx.
|
|
|
|
|
|
How can i use avicap32.dll. in example i found some one user WebCamLib....may i know how can i user it? what reference?
using WebCamLib;
how can i add WebCamLib to my reference?
A S E L A
|
|
|
|
|
Have you tried searching the web, or reading articles on this site ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
yes, and i found
object selectUsingUI = System.Reflection.Missing.Value;
wiaRoot = (ItemClass) wiaManager.Create( ref selectUsingUI );
if( wiaRoot == null )
return;
wiaPics = wiaRoot.GetItemsFromUI( WiaFlag.SingleImage, WiaIntent.ImageTypeColor ) as CollectionClass;
can please explane what happen by this code.....
i can access the webcam. i want to show output in a picturebox now. later capture image.
A S E L A
|
|
|
|
|
can't i use picturebox to camera capture other than using WIA dialog to show....???
A S E L A
|
|
|
|
|
|
How to create the winform with code not by the guide (project-->add-->windows Form) at desgin-time in c#? and how to add some button in the dynamic created winform?
Many thanks
|
|
|
|
|
I would recommend the Petzold book on Winforms, he creates everything in code. To add a button to a form, you create it, and add it to the controls collection of the form. Then you tell it where it sits ( x,y,width,height)
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thank Christian Graus, Could you please tell me the full name of the book ? and in which place I can order it.
|
|
|
|
|
Charles Petzold - Programming Microsoft Windows with C#. Amazon will have it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
How do I use a field storing Type information?
private Type _DataType;
private Dictionary<int, object> _BlobData;
...
_DataType cow = (_DataType)_BlobData[0];
Is "Type" not the right type?
|
|
|
|
|
Generics is how you do stuff like that.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
redivider, to get data out of the dictionary you have to give it the key. In a dictionary, the key is the first type whatever that is. So since you are using an int, then the integer value that you entered must exist in your dictionary, else it will be null.
For a list, this is completely different from a dictionary, and you can just sellect the first field or [0].
int key = 39292;
String testObj = "Hello I'm a string";
object value = (object)testObj;
so in your example... _BlobData.add(key, value);
To get out the value... you have to put in the correct key...
String myOldDefinition = (String)_BlobData[key];
Console.Writeln("My old string = " + myOldDefinition);
HTH,
Marc
Life is too short to program in Visual Basic.
|
|
|
|
|
redivider wrote: Is "Type" not the right type?
It is, but you are casting to _DataType , which is a variable, not a data type. Seems that you are confusing the two concepts of data type and variable (i.e. an instance of a data type). Besides that, the Object.GetType() method is the way to get type information from an object, casting will generally not work.
So your code snippet should read something like this:
private System.Type _Cow;
private Dictionary<int, object> _BlobData;
...
_Cow = _BlobData[0].GetType();
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
|
|
|
|
|
When i have
int i = 10;<br />
i = 5 * i;
it knows i'm not trying to multiply 5 * i, but rather 5* the value stored in i.
So i'm not trying to cast to a variable (_DataType), but rather the value stored in that variable (int, float, string)...
How would generics come into play?
|
|
|
|