|
Hi,
I am using DAAB with stored procedures. I stored procedure is called from multiple functions.
Please guide how I can handle optional parameters with DAAB ? a stored procedure has 2 parameter and values are being passed by functiona1. In function2 I needed to declare 3rd parameter in same stored procedure. I set its default value (so that I may have not to pass it from function1) but even than functions1 stop working and show error message that no of parameters are not same.
I am just selecting data in stored procedure and I have not coded any set statement (like set ansi on or set norowcount) in it.
Please guide me.
thanks
|
|
|
|
|
If you do something like this in method1
<br />
SqlCommand.Parameters.Add( [param1] )<br />
SqlCommand.Parameters.Add( [param2] )<br />
SqlCommand.Execute...<br />
Then this in method2
<br />
SqlCommand.Parameters.Add( [param1] )<br />
SqlCommand.Parameters.Add( [param2] )<br />
SqlCommand.Parameters.Add( [param3] )<br />
SqlCommand.Execute...<br />
as long as SqlCommand is the same object in both methods, then of course calling method1 after method2 will produce this exception, because you do have too many parameters. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks for your kind attention.
I am not using command object. Rather I am passing parameters in directly in database object. e.g.
public int UpdateInvestmentObjectivesNExperience(CorporateAccount obj)
{
int result;
object objResult = db.ExecuteNonQuery("p_corporateaccount_InvestmentObjectivesNExperience", 2, obj .Id,
obj.SpecuativeGains, obj.HedgeAgainstInvestment, obj.InvestmentObjective,
obj.UndarstandNatureOfTCD, obj.UnderstandRiskOfTCD, obj.HaveExperienceOfTCD,
obj.NoOfMonthsExp, obj.TypesOfProductsDealtIn, obj.BrokersUsed, obj.WasAdviceReq,
obj.AvgTransationSize, obj.AvgNoOfTradesPerWeek);
result = Int32.Parse(objResult.ToString());
return result;
}
If I add a new parameter in stored procedure and set its default value by null or 1, than not only I will have to supply value for it in next functions where I am using it rather I will have to supply value for it in this method as well. (for the parameter that is last in stored procedure and has default value.)
Please guide.
thanks gain
|
|
|
|
|
If I understand what you are trying to accomplish then try this.
public int Foo(param1, param2)
{
return Bar(param1, param2, null);
}
public int Bar(param1, param2, param3)
{
return db.Execut(...);
} I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thanks a lot for your kind attention and sharing.
I m exectly doing this now but I here is problem what I asked. On declaring a new parameter I will have to pass value for it in all above functions where even it is not being used.
I was surprised can there be some why I may have not change the code again and again.
thanks
|
|
|
|
|
You want to be able to write one method and never change it again even when you change the stored procedure?
public SqlCommand CreateProc(string procName, ReadOnlyCollection<DbParameter> parameters)
{
SqlCommand cmd = new SqlCommand(procName, SqlConnection);
cmd.CommandType = CommandType.StoredProcedure;
if(parameters != null)
{
foreach(DbParameter param in parameters)
{
cmd.Parameters.Add(param);
}
}
return cmd;
}
I know the language. I've read a book. - _Madmatt
modified on Monday, February 15, 2010 11:40 AM
|
|
|
|
|
Thanks for it.
Can you please explain a little more how it will helpful ? how I can use it ?
thanks
|
|
|
|
|
I thought it was pretty self-explanatory. What don't you understand? I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have a combobox that I fill during the form load. That works fine. The question I have is how do I make it say "Select An Item to autofill" or whatever? I understand I could use selectedindex or something like that but the actually text i wish to display by default is not in the list.
thanks wasn't sure what to search for on this
|
|
|
|
|
I would just add it to the combo data list and then set it to be the selected value. Nothing fancy.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
YEAH makes since to do it that way i guess, but the keywords are tied into each row on the database thats the only problem I have.modified on Sunday, February 14, 2010 3:46 AM
|
|
|
|
|
Hi, im just trying to send OSPF packets to a multicast IP address (224.0.0.5) but, usign raw sockets, windows 7 doesnt allow this type of sockets and using sharpcap i dont find the way to do that (send packets to a multicast ip address).
Please anyone who can help me ???
Im using C#......
|
|
|
|
|
When the connection between server and client break an event is raised,
I catch the event and null the client object but the client keeps on raising the event while it should be destroyed.
|
|
|
|
|
You did not post witch event so I am only guesing.
Maybe your event has e.Handled property. If so try setting it to true.
|
|
|
|
|
it's a custom event:
public delegate void kill(string msg);
public event kill Kill;
if (!clientSocket.Connected)
{
Kill("Server connection broken");
return;
}
Client clnt = null;
private void ms_Startclient_Click(object sender, EventArgs e)
{
if (ms_Startclient.Checked)
{
clnt = new Client();
clnt.Kill += new Client.kill(clnt_Kill);
}
else
{
clnt = null;
}
}
void clnt_Kill(string msg)
{
clnt = null;
MessageBox.Show(msg);
ms_Startclient.Checked = false;
}
|
|
|
|
|
the only thing that could affect yours is that line Kill("Server connection broken"); is being called more than once
|
|
|
|
|
Why dont you just remove the delegate?
void clnt_Kill(string msg) <br />
{ <br />
clnt.Kill -= new Client.kill(clnt_Kill);<br />
clnt = null; <br />
MessageBox.Show(msg); <br />
ms_Startclient.Checked = false; <br />
} Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
You should implement the dispose pattern[^] and dispose of the object. Setting it to null only flags it as being available for cleanup when garbage collection comes around, which you have no idea when will happen. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Your teacher told you to pay attention and not destroy the class.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
I don't know whether I am asking a stupid thing.
I can develop an application that can read emails for me and can send SMS alerts for every new mail.
That application keeps on monitoring my inbox. But I want it to execute 24 hr a day.
Is it possible to make an exe executing all the time online in some other online service or machine.
Something like a program running in cloud(cloud computing)
|
|
|
|
|
Whell, any process can run 24 hours a day 365 days a year. All you need to never close or terminate process or shut-down computer. If you attempt to create process designed for monitoring, then I recommend you to create services.
Gjm wrote: Is it possible to make an exe executing all the time online in some other online service or machine
Normal monitoring application/services needs to be installed on a computer/machines that is supposed to be used.
|
|
|
|
|
You might be looking for a windows service.
Just check whether creating a Windows Service will help you or not.
|
|
|
|
|
Don't post the same question to multiple forums I know the language. I've read a book. - _Madmatt
|
|
|
|
|
this is the code segment i used
int? x = null;
int? y = null;
if (x >= y)
{
Console.WriteLine("x is greater than y ");
}
else
{
Console.WriteLine("x is less than y ");
}
as i read if you compare two nullable types that both are having null it should be true, but i get the false (as in the code "x is less than y " )
can anyone tell me why ?
|
|
|
|
|
If both are null, operator >= can't compare, because it doesn't have value.
prasadbuddhika wrote: as i read if you compare two nullable types that both are having null it should be true
I think if you compares with operator == (Equal) it would be true, because both would be equal.
prasadbuddhika wrote: ut i get the false (as in the code "x is less than y " )
if first block is false then your else block would run instead. However what you want is use this:
if (x > y)
{
Console.WriteLine("x is greater than y ");
}
else if (x < y)
{
Console.WriteLine("x is less than y ");
}
Eidt: Forgot pre tagsmodified on Saturday, February 13, 2010 11:01 AM
|
|
|
|