|
Thanks, but if i are numbers ranging from 1 - 20, how can they be different in all the scenarios you have given me, I mean 1 is 1 and 2 is 2, etc.
|
|
|
|
|
What do you mean? Why would they be different?
---
b { font-weight: normal; }
|
|
|
|
|
What I am trying to ask is why is there like 50 different ways to format an integer?? No matter how you format an integer, lets say for example the number 6, you won't get it to display differently than to a 6.
|
|
|
|
|
Actually, you can format an integer in may ways. For example the number 1234567 can be formatted as:
1234567
00001234567
1,234,567
1234
1,234
000001234
1 2 3 4 5 6 7
0-0-0-0-0-0-1-2-3-4-5-6-7
0000 0123 4567
1
000001
...and so on.
Mostly, though, the different way of formatting values are used with data types like dates and floating point numbers.
---
b { font-weight: normal; }
|
|
|
|
|
Hey..
I see what you mean. But thanks for the effort and time taken to answer my questions.
|
|
|
|
|
Hi.i did a project a that records a transactions that customer make daily something like Bank,so i want to display only transactions that were made by a specific customer using his account number on the datagrid.the problem is it doesn't display the record i that requested it to display only
so i did something like this.
public bool DisplayTrans(string CBarcode2)
{
try
{
conn1= new SqlConnection(ConString);
cmdDisplay1= new SqlCommand();
daDisplay = new SqlDataAdapter();
dsDisplay = new DataSet();
cmdDisplay1.Connection = conn1;
daDisplay.SelectCommand = cmdDisplay1;
cmdDisplay1.CommandText = "SELECT CustomerName,ProductName,Price,EventName,BoughtDate,BoughtTime FROM Transactions WHERE Barcode2 =@Barcode2 ";
SqlParameter Bar = new SqlParameter();
Bar.ParameterName = "@Barcode2";
Bar.Direction = System.Data.ParameterDirection.Input;
Bar.Value = CBarcode2;
cmdDisplay1.Parameters.Add(Bar);
daDisplay.Fill(dsDisplay,"Transactions");
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
return false;
}
return true;
-- modified at 5:31 Thursday 24th August, 2006
|
|
|
|
|
I assume that you have a problem with this code, and you're not just sharing it for fun ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Actually this is quite useful. I've been awake all night try to figure out how to how query the database and fill a dataset. I could have gotten more sleep if I'd have only waited for this post.
only two letters away from being an asset
|
|
|
|
|
|
hi all,when i send the mail using smtp server(localhost) i can't receive any mail in the mailroot folder(even with out any error) what will be the problem....
here is my code........
SmtpMail.SmtpServer="localhost";
MailMessage msg=new MailMessage();
msg.To=txtto.Text;
msg.From=txtfrom.Text;
msg.Subject=txtsub.Text;
msg.Body=txtmsg.Text;
SmtpMail.Send(msg);
ayyp
|
|
|
|
|
ayyp wrote: SmtpMail.SmtpServer="localhost";
is your computer a smtp server?
if not, please change this to a right one.
|
|
|
|
|
if we set like SmtpMail.SmtpServer="localhost";then it will drop the mails in inetpub\mailroot\draft... am i correct....?
ayyp
|
|
|
|
|
I don't know.
you can test it. if you find the email you send to localhost, you are correct.
|
|
|
|
|
Im a VB.NET programmer currently working with C#, I am having following questions.
How to create a function with optional parameters ?
Is there any function exist like "CallByName" in VB.NET ?
|
|
|
|
|
iprasad007 wrote: How to create a function with optional parameters ?
And in a matter of moments, you've found the one thing that VB.NET has and C# does not. I have complained to the C# team, they don't care.
So, you need to create two methods, one with the extra param, and one that calls the extra param version with the default. Sucks, I know.
iprasad007 wrote: Is there any function exist like "CallByName" in VB.NET ?
Depends, what does it do ?
Just googled. VB.NET still does that ? That sucks. You should stay clear of anything in the VisualBasic namespace, that's .NET pollution right there. You can use reflection to find methods on an object, perhaps that will do what you need here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you so much Christian.
So in first case I need to code same Business Logic twice, or is there any standard method to write the function once and prototyping it many times ?
For instance I can write function with all params ones, then can write many functions with same names but with few parameters then of original. But still i need to write code to call original function hence the overhead of maintaining all the functions (while change or documentation). Is this is the last way to do ?
And now about my second question, sorry really I didant got what shud I do when I need to call a function or set a property by softcoding such as CallByName does in VB.NET.
Waiting for your reply
Prasad
P.S. BTW ur blog is good
|
|
|
|
|
iprasad007 wrote: P.S. BTW ur blog is good
*blush* thanks. I need to post something on it tho.
iprasad007 wrote: So in first case I need to code same Business Logic twice, or is there any standard method to write the function once and prototyping it many times ?
Only ever code your business logic once. Like this
int SortStuff(SortBy sortBy, SortOrder sortOrder
{
// lots of sorting code
}
int SortStuff(SortBy sortBy)
{
return SortBy(sortBy, SortOrder.Ascending);
}
Note, the enums in this method are made up to make the point.
iprasad007 wrote: And now about my second question, sorry really I didant got what shud I do when I need to call a function or set a property by softcoding such as CallByName does in VB.NET.
Why would you want to do such a thing ? I think it sucks, I don't see how that method is in any way validating that the method in question exists. If you want to discover methods and call them, you need to use reflection ( google reflection C# and you'll see it's a complex subject, but it's exactly what you need here ).
Worst case scenario, you can import the VisualBasic dll/namespace into yuor C# app and call the old VB methods, but ideally you shouldn't do that, even if you're using VB.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Worst case scenario, you can import the VisualBasic dll/namespace into yuor C# app and call the old VB methods, but ideally you shouldn't do that, even if you're using VB.
No no I would not do that. I need such functionality for a usual requirement, i.e. to clean all controls in a container. As usual I have wrote a foreach control block for looping through all the controls, depending upon controls type im planning to call its clear method or .Text = "", some controls on my form or container requires some other methods to clear them. Hence needed that function.
I think I need to dig in reflection.
Thanx for ur replies.
(In persuit of reflection)
Prasad
|
|
|
|
|
If that's all you need, then you can use as.
For example
foreach ( Control c in Controls)
{
TextBox t = c as TextBox;
if (t != null ) // c was a TextBox
{
t.Whateveryoulike
}
// and so on
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Great tip indeed ...
I have done by following way,
foreach(Control ctl in this.Controls)
{
if(ctl.GetType() == typeof(TextBox))
{
TextBox t=ctl as TextBox;
t.Text ="";
}
else if(ctl.GetType() == typeof(CheckBox))
{
CheckBox t=ctl as CheckBox;
t.Checked =false;
}
}
Thank you so much for ur kind help, now im feeling that im doing it in right way, and also i havent forgot to write ur name in comment of my code (alog with url to this page).
(Gr88 C# Expert)
Prasad
-- modified at 6:37 Thursday 24th August, 2006
|
|
|
|
|
Hello,
You better should go on with what Christian Graus told you.
foreach ( Control c in Controls)
{
TextBox t = c as TextBox;
if (t != null ) // c was a TextBox
{
t.Whateveryoulike
}
else
{
CheckBox cb = c as CheckBox;
if(cb!=null)
{
cb......
}
}
In youre case you ask the Type info 2 times. (takes a little longer)
(I also learned it some time ago, from Christian Graus I think)
All the best,
Martin
|
|
|
|
|
As someone said, typeof is kind of redundant. The only reason I can see to use it is that you may be able to switch on ctl.GetType(), and a switch is always better than lots of else if statements.
I'm sure that 'as' would use getType, so the most efficient way if a switch won't work would probably be to store the result of typeof(ctl) and use it without calling it every time.
-- modified at 7:11 Thursday 24th August, 2006
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanx Christian and Martin ... i would do by the way u both suggested .. i understood that it is optimum ... thanx alot
(Thinking Outside The Box)
Prasad
|
|
|
|
|
Hi All Respected Programmers
VB6 Method => Form2.Text1.Text = Form1.Text1.Text
Kindly guide me, how may I use said method in C# ?
Thank you very much in Advance
|
|
|
|
|
You need to create objects of both the forms and then u can use same code just by adding semicolon after it, such as
Form1 x=new Form1();
Form2 y=new Form2();
x.Text1.Text=y.Text1.Text;
|
|
|
|