dickersonka 104 Veteran Poster

A common question that routinely comes up is how to share data between forms.

I have outlined two common ways to pass data between forms, among many others. I have used a public property on the output form to accept a value and update the display. I also have a method accepting parameters from the input form, to update the display.

On the first form there are three textboxes tbFirstName, tbLastName, and tbSample with a Submit button to redirect to the output form. I have the same layout on the output form to display the passed values.

dickersonka 104 Veteran Poster

The problem with that would be is that its not a singleton and can exist in multiple classes

private static readonly GlobalVariables TheSingleGlobalVariableInstance = new GlobalVariables();

        private GlobalVariables()
        {
        }
           
        public static GlobalVariables  Instance
        {
get
{
            return TheSingleGlobalVariableInstance;
}
        }

The above piece allows only a single instance to exist in the application, which can be called by any class without creating an instance of it

//you can do this
GlobalVariables.Instance.Result6 = 5;

//you can't do this
GlobalVariables gv = new GlobalVariables();
gv.Result6 = 5;

you normally would use this singleton method for a configuration accessor class or a group of data that needs to be shared throught the app without passing a class object around

ddanbe commented: good explanation +4
dickersonka 104 Veteran Poster

The exe is the compiled solution, all exes have already been compiled as well

if you are in a winforms app, it needs to be compiled before running it, if you are in asp.net you can set the project not to be built until specifically build the project

if your project is getting to be that large, then possibly separate your reference dlls out into a separate solution, and build those when necessary, and have the main app reference the dlls rather than projects

alc6379 commented: very good real-world use case here. +12
dickersonka 104 Veteran Poster
select top 3 *
from tableName
order by col3 desc
bharatshivram commented: thanx for your reply. +2
dickersonka 104 Veteran Poster
System.Diagnostics.Process.Start("calc")
chitopolo commented: Thank You very much i was looking for this code like since 2 hours ago..! Thank u again! +0
dickersonka 104 Veteran Poster

i'm not quite sure what you are trying to do here, but there are 2 things

first you are referencing R3 outside of its scope, second you have a where instead of an and, here is my shot at what i think you are trying to do

select * from Results RT1 
where RT1.RDate = (select max(RT2.RDate) from Results RT2)
and RT1.RTime = 
 (select max(RT3.RTime) from Results RT3
   where RT3.RDate = (select max(RT4.RDate) from Results RT4))
Eager_Beever commented: Thanks for pointing out my mistake. +2
dickersonka 104 Veteran Poster

Ok, just wanted to make sure we aren't chasing a ghost

Rather than just adding the parameters with a name and value, try to add them with a name and type

SqlParameter param1 = new SqlParameter("@RDate", SqlDbType.DateTime);
param1.Value = dtCurrentDate;
sqlCmdCheckDuplicates.Parameters.Add(param1);

and do the same for the other one

dickersonka 104 Veteran Poster

sorry bout that, was a late night and didn't think twice about it

this will work

select
(select count(*) from posts p1 where p1.user_id = u.user_id) as post_count,
u.user_id
from users u
left outer join
posts p
on p.user_id = u.user_id
group by u.user_id
nav33n commented: works great.. +10
dickersonka 104 Veteran Poster

right, then the exception is correct

uri is expected to be a registered prefix, and javascript is not, things are working properly!!!

dickersonka 104 Veteran Poster

are you meaning something like this?

foreach (HtmlElement link in webBrowser1.Document.Links)
            {
                bool isValid = false;
                string linkItem = link.GetAttribute("HREF").ToString();
                
                Uri urlCheck = new Uri(linkItem);
                WebRequest request = WebRequest.Create(urlCheck);
                request.Timeout = 10000;    // 10 seconds


                WebResponse response;
                try
                {
                    response = request.GetResponse();
                    isValid = true;
                    Console.WriteLine("Good");
                }
                catch (Exception)
                {
                    Console.WriteLine("Bad"); //url does not exist
                }
                
               if(isValid)
	   {
		listViewLinks.Items.Add(link.GetAttribute("HREF").ToString());
	   }
	}
dickersonka 104 Veteran Poster

ok we see your assignment, what have you done so far, what are you having trouble with?

dickersonka 104 Veteran Poster

here i found an article on the suggestion i gave you earlier

its because order of precedence, also always try to do joins this way, makes much cleaner code

http://damonparker.org/blog/2006/02/23/mysql5-join-syntax-changes/

filch commented: Once again, a great help! +1
dickersonka 104 Veteran Poster
select db_name()
omrsafetyo commented: It seems so obvious... +1
dickersonka 104 Veteran Poster

actually no need to check the uas table at all, just delete, then insert

you are correct, check user table i guess from a login or whatever that is, then no need to check anything against uas table except when displaying the form, on submit delete and insert

also i normally wouldn't suggest this, but i think it is appropriate here, we don't need a uas_id on uas table, it is always being deleted and never referenced, you can keep it, no big deal, its just not of use i see yet, but maybe keep it if you think you will need it later

filch commented: This man is amazing ... really! +1
dickersonka 104 Veteran Poster

you are correct, String.split is the way to go to treat it the same as the tokenizer

the other way would be to use regex

dickersonka 104 Veteran Poster
select DATEDIFF(now(), '2008-12-25)
CodeBoy101 commented: Great!!! (^ - ^) +1
dickersonka 104 Veteran Poster

lol yeh man, it worked fine, will you post the whole class structure then?

ddanbe commented: inspiring +2
dickersonka 104 Veteran Poster

are you catching the key press event and checking for enter?

if ((int)e.KeyChar == (int)Keys.Enter) 
{
Navigate(toolStripTextBox1.Text);
}
dickersonka 104 Veteran Poster

perfect english :-), lol well at least typing

maybe when the users are on the system tomorrow, run show processlist again, and you can see what may be causing the problem

123468743867143 commented: Simply awesome. Lots of useful information. Very patient with inexperienced person like me. Thank you "Dickersonka". +1
dickersonka 104 Veteran Poster

depends upon the context, a lot of times you will check to see if bytesRead > -1 or sometimes you check for CRLF (carriage return line feed), other times you will pass how many bytes you will be sending and read until all the bytes have been sent

Antenka commented: Thanks againg for goog and quick help! +1
dickersonka 104 Veteran Poster

ahhh i see now, i know you may not like the idea, but just name the checkboxes as groups when you are displaying them, on postback only grab the ones for the selected airport (also for each airport)

<input type="checkbox" name="YVR[]" />
<intput type="checkbox" name="YYC[]" />
filch commented: Great patience and good advice. +1
dickersonka 104 Veteran Poster

are you wanting dynamic variable names?

if so you can't do that in java
you can use an ArrayList or HashMap to store a name and a class

String userSpecifiedName = "SunServer";
HashMap<String, Simple> map = new HashMap<String, Simple>();

Simple simpleClass = new Simple();
map.put(userSpecifiedName, simpleClass);
Ezzaral commented: Yeah, he seems to be wanting a map. Not a very clear question though :) +15
dickersonka 104 Veteran Poster

sorry, forgot it was java, here's a sample java tcplistener

http://www.koders.com/java/fid857615100E60AA30093DF6D87C3135D7AE75C4F5.aspx

Antenka commented: Thanks a lot!!!!!!!!!!! +1
dickersonka 104 Veteran Poster

if you use fxcop or code analysis in visual studio there is a rule CA1806 to 'do not ignore method results'
http://msdn.microsoft.com/en-us/library/ms244717(VS.80).aspx

ddanbe commented: Thanks for the help +2
dickersonka 104 Veteran Poster

friend lol, we do seem a bit hostile
i can bet this is the sharekahn app i have saw tons of problems about

just because i am nice, check out this link, the bottom post
http://forums.sun.com/thread.jspa?threadID=776507

VernonDozier commented: +rep for mind reading ability. I had no idea what the OP was talking about. +8
dickersonka 104 Veteran Poster

you can pass parameters using

<applet .....
<PARAM name="param" value="value">
</applet>

in your init

String param = getParameter("param");

just do conversion to int, but you are specify width and height already, but thats how pass them

dickersonka 104 Veteran Poster

ahhh, math junkie then lol


this might be helpful as well, more of the logic side, than the graphical
http://bytes.com/forum/thread645269.html

coveredinflies commented: Thanks +1
dickersonka 104 Veteran Poster

how about

int myValue = 6000;
Debug.WriteLine(Convert.ToString (myValue, 2));

little less lines of code

ddanbe commented: nice! +2
dickersonka 104 Veteran Poster

Rude, for giving him a link with what it is with code and saying to clarify the question?

Doesn't look like a good way to start off here RC131, when we are trying to help.

ddanbe commented: well said +2
dickersonka 104 Veteran Poster

here is the sql code to get it

SELECT
sysobjects.name AS "TABLE_NAME", 
syscolumns.name AS "COLUMN_NAME", 
systypes.name AS "DATA_TYPE", 
syscolumns.LENGTH AS "LENGTH" 
FROM         
	sysobjects 
INNER JOIN 
	syscolumns ON sysobjects.id = syscolumns.id 
INNER JOIN                      
	systypes ON syscolumns.xtype = systypes.xtype 
WHERE     
(sysobjects.xtype = 'U') and
sysobjects.name = 'MyTableName'
ORDER BY sysobjects.name, syscolumns.colid

then in your your datacolumn, you will set maxlength to the value returned from the query for length

ddanbe commented: whew cool! +1
dickersonka 104 Veteran Poster

manipulate the filename before creating the saveFile

string newFile = FileUpload1.FileName;
newFile = "myfilename_" + newFile;
saveFile = Path.Combine(savePath, newFile);
bharatshivram commented: thanx for the reply.. worked fine +2
dickersonka 104 Veteran Poster

also you will crash out past once x hits 10, your table is only of size 10

Alex Edwards commented: Good catch =) +4
dickersonka 104 Veteran Poster

In the instructions it states:

As you can see from the above two runs, the user will be asked to specify the size of the twodimensional
array. So if the user inputs the value (5), then the array should be of the size [5][5].

The elements of the
array are instances of the class “Cell” which is included as one of the three files. This class must
have one data field only:
private String color;


Your cell implementation doesn't fit the instructions.

Take time and read before you start coding. This isn't the easiest problem in the world, nor hardest, but not one to go haphazardly into. Break it into steps. I see you are in Algorithms and Data Structures, and I'm sure they aren't teaching code first.

Ezzaral commented: More patience than this poster has earned. +13
dickersonka 104 Veteran Poster

and btw, i left the \n endl because you had it in there

normally you would use one or the other, but for this i would say drop the \n and stick with the endl

ddanbe commented: Ah! +1
dickersonka 104 Veteran Poster

i think maybe a small correction to that, since he is getting them from the newEmployee object

string sql = "INSERT INTO employeeTable(EmployeeName, Salary) VALUES ('" + newEmployee.EmployeeName + "', " + newEmployee.Salary.ToString() + ")";
ddanbe commented: Errare humanum est! Aways correct me if you think you must. +1
dickersonka 104 Veteran Poster

Lol agree with ddanbe, like we told you yesterday use
tbSendText.Text

And just to shed some light on what the other guys are saying about the crlf (\r\n), the socket you are connected to needs to know when you are done sending. Since you can send 5 bytes, then later 10 bytes for example, you must tell the connected socket when you are done. The crlf typically is used to say "i am done", then the response is sent back from the connected socket.

ddanbe commented: respect +1
dickersonka 104 Veteran Poster

The issue is because you are placing the constraints on the same table

Think of it this way, if you remove a trip in the middle of the sequence, it will cause all other trips that are fk'd from it to be deleted as well

do as the error message tells you and on your fk's instead of on delete cacsade, set to on delete no action

darkagn commented: Good explanation :) +3
dickersonka 104 Veteran Poster
toadzky commented: Perfect. +2
dickersonka 104 Veteran Poster

also before adding the items, make sure you call

this.comboBox1.Items.Clear();
dickersonka 104 Veteran Poster

Yes, I thought you made a custom wrapper around it that only accepted a char.

Anyways here's a link
http://forums.msdn.microsoft.com/en-US/netfxbcl/thread/ebf6b7f4-123c-4de0-b331-2ea74769c94d/

Duki commented: Good link. +7
dickersonka 104 Veteran Poster

i'll stick with the coalesce

make sure your join is on the column that will be in both tables, use a left join, and make sure to use an alias on your coalesced column

[B]left join [/B]avatars
on [B]members.user_id = avatars.user_id[/B]
dottomm commented: Thank you. All your help is greatly appreciated! +1
dickersonka 104 Veteran Poster

For this you can use a query string or session, query string might be easiest.

[B]connect.aspx.cs[/B]
protected void picUpload_Click(object sender, EventArgs e)
{
int year = 1870;
Response.Redirect("upload.aspx?year=" + year.ToString());
}

in the receiving page
private void Page_Load(object sender, System.EventArgs e)
{
int year = Convert.ToInt32(Request.QueryString["year"]);
}
anitha joe commented: Really Helpful +1