|
if you lookad at you own code then you see your run a for-loop
place my code in your for loop!
|
|
|
|
|
bool isCheckedIgnore = ((CheckBox)row.FindControl("chkIgnoreItem")).Checked;
this will always return true coz u r by default giving value as checked
i think this is the reason for that if not please let me know
|
|
|
|
|
I can't change the field to bit, it needs to stay as nvarchar.
rajkumar.3 wrote: this will always return true coz u r by default giving value as checked
Im not sure on that because its finding the control and setting isCheckedIgnore to the result of that, therefore if the textbox is not ticked it should skip the first statement below and do the second
if (isCheckedComponentIgnore == true)
{
}
else
{
}
|
|
|
|
|
ok slightly seperate problem but related
ive got the following code which is binding data which is not a bit field but a varchar and contains Y or N in the column. The code below produces the error:
"Specified cast is not valid."
stringvalue = (bool)DataBinder.Eval(e.Row.DataItem, "fieldname");
however if I change the column to bit i.e. 1 and 0 it works.
Is there a way I can change the code so that it works without changing the column to 1 and 0 i.e. bit!
cheers
|
|
|
|
|
for (i=1;i=5;i++)
{
int a=i;
sqlinsert="update tbl_name set loop_no=a where rollnumber=a";
cmd = new SqlCommand(sqlinsert, conn);
try
{
cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
FileStream fs;
StreamWriter sw;
fs=new Filestream("logfile.txt",FileMode.open);
sw=new StreamWriter(fs);
string newline="Roll No:"+a+"was not updated";
sw.close();
fs.close();
}
}
once if its go for "CATCH" block, how it can proceed others?
i.e, if record 2 fails, will it proceed other records and complete the whole FOR loop????
i tried.. but getting error...
how to achieve it?
thanks in advance and understanding....
|
|
|
|
|
Since this is not VB6 and you cannot Resume Next On Error, I guess you better validate what you're updating before trying to update it, and if it doesn't validate, not try to update. Simply. Thus, you get no exceptions and the for loops for as long as you want it to loop
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
John Sundar wrote:
once if its go for "CATCH" block, how it can proceed others?
i.e, if record 2 fails, will it proceed other records and complete the whole FOR loop????
The try/catch block is within the body of the loop. If an error occurs during one iteration of the loop, it will be caught and the code will proceed to subsequent iterations.
John Sundar wrote: i tried.. but getting error...
You need to post details of the error if you want help. We're not mindreaders.
John Sundar wrote: how to achieve it?
Post details of your error, and maybe you'll get some help.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
how to use the date concept in .net with C#
|
|
|
|
|
, obviously hasnt read any of the posts on this page about using google for questions
|
|
|
|
|
In his previous post itself it was mentioned that these questions can be answered easily on google.
Apurva Kaushal
|
|
|
|
|
nithydurai wrote: how to use the date concept
Please be more clear. I observe that variants of this question is scattered across the forum aplenty. Posting the same query multiple times actually dissuades focussed experts in helping out rendering your request futile.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
i am using date concept.i get system date.but i host the project in website.it will be run.i am using the query select * from tablename where date='"+systemdate+"'.i have one dought i donot open website,how it's run.it will run or not.if you know the answer replay to me..
|
|
|
|
|
Can you write your question in somewhat better manner. It is not at all clear what you want to ask.
Apurva Kaushal
|
|
|
|
|
i am using --->
string month, yearr, datee, systemdate;
month = DateTime.Now.Month.ToString();
yearr = DateTime.Now.Year.ToString();
datee = DateTime.Now.Day.ToString();
systemdate = Convert.ToString(month.ToString()) + "/" + Convert.ToString(datee.ToString()) + "/" + Convert.ToString(yearr.ToString());
SqlConnection con = new SqlConnection("server=.;initial catalog=master;user id=sa;password=sa;");
con.Open();
SqlCommand cmd = new SqlCommand("delete from no where date='" + systemdate + "'", con);
cmd.ExecuteNonQuery();
con.Close();
this is my code. systemdate reach the date it will be delete.but i host the project in web.how it is work?
replay to me...
|
|
|
|
|
sugunavathysubramanian wrote: string month, yearr, datee, systemdate;
month = DateTime.Now.Month.ToString();
yearr = DateTime.Now.Year.ToString();
datee = DateTime.Now.Day.ToString();
systemdate = Convert.ToString(month.ToString()) + "/" + Convert.ToString(datee.ToString()) + "/" + Convert.ToString(yearr.ToString());
SqlConnection con = new SqlConnection("server=.;initial catalog=master;user id=sa;password=sa;");
con.Open();
SqlCommand cmd = new SqlCommand("delete from no where date='" + systemdate + "'", con);
cmd.ExecuteNonQuery();
con.Close();
Buy a basic programming book, there are so much chaff in the above that it is impossible to guide you.
eg.
Convert.ToString(yearr.ToString()); <-- anything strike you as redundant in this snippet?
|
|
|
|
|
sugunavathysubramanian wrote: new SqlConnection("server=.;initial catalog=master;user id=sa;password=sa;");
Your database administrator should really be kicked with a wet towel till he understands the folly he has created:
1) Allowing others to tamper the master database
2) Having a weak password for sa account.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Completely agree. Please, the English language has tools for letting people understand each other.
Anyhow, maybe you should consider changing the query and use the DB server date, something like SELECT * FROM tablename WHERE date = GETDATE() [if on SQL Server].
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
we are not opening the website.ok how to get system date ..do u get my point.
|
|
|
|
|
sugunavathysubramanian wrote: we are not opening the website.ok how to get system date ..do u get my point.
How do you expect the code to be executed if the website isn't running?
You do understand how websites, the internet and the HTTP protocol works, don't you?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
No idea about what you really mean with 'not opening the website' , but anyhow, in the code you posted before...
string month, yearr, datee, systemdate;
month = DateTime.Now.Month.ToString();
yearr = DateTime.Now.Year.ToString();
datee = DateTime.Now.Day.ToString();
systemdate = Convert.ToString(month.ToString()) + "/" + Convert.ToString(datee.ToString()) + "/" + Convert.ToString(yearr.ToString());
SqlConnection con = new SqlConnection("server=.;initial catalog=master;user id=sa;password=sa;");
con.Open();
SqlCommand cmd = new SqlCommand("delete from no where date='" + systemdate + "'", con);
cmd.ExecuteNonQuery();
con.Close()
What about...
SqlCommand cmd = new SqlCommand("delete from no where date= GETDATE()", con)
That's what I originally meant.
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
I would suggest you two things:
1) Prefer stored procedures instead of such queries.
2) Use Google first. These are little queries that Google can help you in a jiffy without having to wait for some one to respond and assist you through.
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Dear All,
I have requirement like creating a word document with some data. Once it is created , that word document should me saved on the client system.
Please help me solve this.
|
|
|
|
|
Search the web for 'Word automation' and you'll find plenty of information on controlling Word programmatically.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Thanks for your replay,
I am able to create word document by Application Class. What i required is once the document is created
it should prompt to user to save or open the document in other window.
|
|
|
|
|
Then you can temporally save the file on the server, then redirect the user to the file, and browser should automatically prompt the user to save or open the file. I believe...
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|