|
1. The "}" below my if statement
2. c_code always has data in it...but can you please explain to me the concept on why it shouldnt always be empty? Thanx!
3. sys_colors=systems colors. It's a table full of colors for each part of the company website
3.a. I've the Connection.Open(); part above my form.
Kampai!!!
|
|
|
|
|
if (Page.Request.QueryString["Mode"] == "Delete")
{
objCol.DeleteColors(Page.Request.QueryString["key"],""); // 2 - you always pass an empty string to compare with c_code, so it will never do anything anyhow
Response.Redirect ("SysColors.aspx");
}// 1. If it hangs here, then there's nothing else for the debugger to show you, it's gone off to another form. Put a break point in the other form to see if it gets there. I assume you've stepped through to see the rest is executed ?
//objCol
public bool DeleteColors(string strObject,string strColors)
{
try
{
strSQL = " DELETE FROM sys_colors";
strSQL += " WHERE object = '" + strObject+ "' ";
strSQL += " AND c_code = '" + strColors + "' ";
OdbcCommand cmdDelete = new OdbcCommand();
cmdDelete.CommandText = strSQL;
cmdDelete.Connection = cnnDS;
cmdDelete.ExecuteNonQuery();
return true;
}
catch (Exception e)
{
throw e;
}
3 - sys_ is the prefix for system tables, so why are you using it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
oh...darn. About the sys_ its a pre made table by the other programers God knows who. So the 2nd parameter is what keeps it from doing anything coz its set as "".
Yeah everything else is executed except for this delete button and a slight problem in my save button. It's suppose to save the color on only one row however it saves a color i choose for every row. I guess i should explain that a color is asigned for every part of the website. For example the background color is blue then the forecolor is red. What happens is when i choose for example again green to be set as the background color, green is also set for the rest of the parts. Well thats a different problem altogether right...?
Kampai!!!
|
|
|
|
|
tatchung wrote:
About the sys_ its a pre made table by the other programers God knows who.
There's no naming conventions on this app ?
tatchung wrote:
the 2nd parameter is what keeps it from doing anything coz its set as "".
OK, that's by design for now ?
tatchung wrote:
Well thats a different problem altogether right...?
Yes, sounds like the SQL is flawed there.
So did you try a break point in the other page ? Does the SQL execute ? I guess it's hard to say, seeing as it does nothing right now.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah it the SQL executes then when it goes back to my UI then it hangs at the bracket shown earlier. I've tried removing the Response.Redirect(SysColors.aspx); line then the delete button fires but now it doesn't do anything at all.
Im really sori for all the trouble. Im still learning c#. Thanks for your undying patience
Kampai!!!
|
|
|
|
|
tatchung wrote:
Yeah it the SQL executes then when it goes back to my UI then it hangs at the bracket shown earlier. I've tried removing the Response.Redirect(SysColors.aspx); line then the delete button fires but now it doesn't do anything at all.
Like I said, you need to put break points in the new page, to see if the redirect ever gets there. And it doesn't do anything at all for the reason I said before, you need to pass in something other than an empty string for that second value.
tatchung wrote:
Im really sori for all the trouble. Im still learning c#.
It's no trouble, that's what these boards are for. If I decide it's too much trouble, I'm free to not respond, and someone else will.
I've been developing for about 6 years, and nowadays I have a goodjob, and a number of contract jobs I do on the side, giving me an above average income, doing things I love. Everything that I achieve now, is as a direct result of me asking far more stupid questions than these on these same boards 6 years ago, and other people answering them. ( I'm self taught ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I did actualy and it does arrive at the other form. Yeah i figured it has something to do with the 2nd value being set to "".
Thanx Chris! Looks like I'l be following ur path since im self-studying as well. I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills...interesting...how did I get to c#? Oh well! Thanks again! Till my next stupid post!
Kampai!!!
|
|
|
|
|
tatchung wrote:
Yeah i figured it has something to do with the 2nd value being set to "".
That should really just cause the SQL to do nothing, I'd have thought.
tatchung wrote:
I've no idea whatsoever on programming and being an intern in a company gave me the opportunity to initialize my technical skills
What's an intern, is it like an entry level position ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
intern = ojt = on the job trainee.
I'm a management student but the only opening i got for my ojt was this programmer position. So as you can see...it really is hard for me to study under certain conditions given by the company and intense time pressure pressed by some of our clients. But don't get me wrong...I enjoy working my mind in programming and i enjoy programming per se. It sorts of develop self awareness and of course...my chess skills!
Kampai!!!
|
|
|
|
|
OK - I see. I've heard the term often, but wasn't sure what it meant. Management->programming, that's quite a leap. Good luck with it all !!!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanx! I'd make good on this!
Congratulations on your acheivements Chris and Gud luck to you in the future! Till my next post!
Kampai!!!
|
|
|
|
|
Hey Chris! I was wonderin if you could spare a minute of ur time to help me out with this simple problem.
Regarding the delete button we've discussed before...yeah i finally made it work but there's just one slight problem...I've 2 entries in my dropdown list..."CompanyA" and "CompanyB" where "CompanyA" populates the top index of the dropdown list. Now everything works smoothly even the delete button but when I choose "CompanyB" and delete a data from its queries it deletes a data from with the same object from "CompanyA". I've been bugging the whole day about this problem. Here's my new code in the delete button
if (Page.Request.QueryString["Mode"] == "Delete")<br />
{<br />
objCol.DeleteColors(Page.Request.QueryString["key"],ddl.SelectedItem.Text);<br />
}
I've tried debugging and used "? ddl.SelectedItem.Text" (i'm not sure what that is called) which still retuned "CompanyA" even though I chose "CompanyB".
Thanx in advance!
I didnt create a new thread...figured u'd reply faster here. Hehe...sori for the inconvinience.
Kampai!!!
|
|
|
|
|
Looks to me like you databind with your data source on postback, which will reset the item selected.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I get the name of the control in string format in an event: "control1"
And I want to modify its properties (for ex.: control1.BackColor = Color.White;
How can I convert or point this string to the existing instance of the control??
regards
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Reflection.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks Christian but it's a huge namespace for me to solve this issue right now. I tried PropertyInfo and checked the MemberInfo classes but still found no answers.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
You're saying that reflection is a huge space to learn, or that you're working in a huge namespace ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I meant the Reflection namespace is huge but still I need to learn that. It's just that it's 5 am and I have a little time to finish what I'm writing. that's all.
Anyway, thanks for the help..
I think I should use MemberInfo class and tried smth like this:
<br />
System.Reflection.MemberInfo[] myMembers = ....GetType().GetMember("pictureBox1");<br />
this.Controls.Remove(myMembers[0]);<br />
on it..
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
No, I don't think that's the way to go. Sorry, I don't know a lot more, but definately reflection is the only way you'll get variables out of names, unless you build a hash table before you start and look it up.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hmm.. if only there was an equivalent like java's eval function... but no..
thanx for your time
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Well friend I don't have fancy solution like reflection but this should do the trick... I bet 90% of people are using it... hey -> not all of us are MVPs ... NHF? I'm just kidding
<br />
foreach (Control c in this.Controls)<br />
{<br />
if (c.Name == "control1")<br />
{<br />
}<br />
}<br />
Now if ur's event isn't in form which control u need to modify, than you'll need to pass that form, or it's collection Controls. Drop a line if u need more hints...
|
|
|
|
|
I thought about this method but I need to do it without loops.. It will slow down the app...
thanks anyway.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
you may
use reflection to get the type by name
and then call InvokeMember
|
|
|
|
|
Not sure if this'll compile, but I've done something similar to this:
<br />
string controlname = "control1";<br />
string propertyname = "BackColor";<br />
object newvalue = Color.Black;<br />
Control control;<br />
<br />
control = form1.GetType().InvokeMember( controlname, BindingFlags.Instance|BindingFlags.GetField, null, form1, new object[] {} );<br />
control.GetType().InvokeMember( propertyname, BindingFlags.Instance|BindingFlags.SetProperty, null, control, new object[] { newvalue } );<br />
--
Joel Lucsy
|
|
|
|
|
Hi All,
Just wondering if there is a way to change code access permissions (is that the right phrase?) from within the actual code at runtime?
Is this possible? I am writing some network tools and the network I am on has restrictions on .NET applications running. I was need to temporarily give the code access to certain areas of the system and then once the job is done, remove them.
Thanks for the help, sorry if this is a really noob question.
|
|
|
|