f1 fan 16 Posting Whiz in Training

Why not just use the datalist control? You have full control over it then and much better for your situation than the grid

f1 fan 16 Posting Whiz in Training

Your select command is wrong... you have where vaNAME like '%@vaNAME%' and ... where it should be where vaNAME like '%" + @vaNAME + "%' and ... Just as a matter of advice try to ALWAYS use stored procedures instead of writing sql queries in code. a few reasons - the main one is security i can bet money that you dont verify the text in the textbox is not sql commands and i would be in your database within 10 seconds (you wont believe the number of websites you can get into just from the login page - it is called SQL Injection and is usually number 1 on the hackers try list as it is so easy). What if i typed in the textbox something like this (pay attention to the ' ) in the textbox when you asked for my name... fred ' delete from master .... your whole sql server is wiped out now. took me less than 10 seconds. my simple ' in there closed your where clause (if you dont believe me go look at the sql statement with my text substituted for the variable) and allowed me to run my delete sql statement (yes you can have multiple sql statements one after the other, they dont have to finish before sending the next one)
So that is the main reason to use stored procs - you dont put in the ' round text so no sql injection can take place. The second …

red_evolve commented: Thank you very much for the valuable lesson :) +4
f1 fan 16 Posting Whiz in Training

hahaha you couldnt afford my rates :p

f1 fan 16 Posting Whiz in Training

I was unsure of how your parent and child windows were related and also was giving a general way of achieving it instead of the specific code for your situation. But to answer your question. In your case the LoadDataGrid would have no parameters and from the mdi parent you would just call activemdichild.LoadDataGrid() when you needed it filled. Remember in the child windows to make the LoadDataGrid() internal so the mdi parent can call it

f1 fan 16 Posting Whiz in Training

no because your chart says if it is not c then it can go to F without worrying about d. I had the c AND not d and changed it. Which means it is While not(not c or d) Thats dragged up some old De Morgans Theorum from years back then :D At least i think it is his (change ands to ors and ors to ands, not each individual and then not the lot)

f1 fan 16 Posting Whiz in Training

which is almost the same as yours except i included the B (no biggie) and no extra variable needed hence performance should be marginally better.

f1 fan 16 Posting Whiz in Training

you missed out B!
Try
A
While c or not d
(
B
if not d then do E
)
F

f1 fan 16 Posting Whiz in Training

Seems like i am your personal tutor huh? :p Anyway yes. System.Diagnostics.Process. There are a number of ways to get it to go. But in your case pass it the tecplot.exe path and the dat filename as a parameter (or it may need the dat file itself - i dont know about tecplot so wouldnt know) and tell it to start....

ProcessStartInfo myProcessStartInfo = new ProcessInfo(tecplot.exe path); //assuming you have the "using" statement
myProcessStartInfo.Arguments = datfilename;
Process.Start(myProcessStartInfo);
f1 fan 16 Posting Whiz in Training

ok not quite the way to go about it but would work. First some good programming standards advice - NEVER code in an event handler (eg button click event). Code in a method and call that method from your event handler. Why? Because it is reuseable and a lot more maintainable. It would also help you in this case.

So lets say you had your dataloading method
internal void LoadDataGrid(parameters)
{
}

we made it internal for a reason as you will see in a minute.
You can call that at anytime in your form (form load, form activate, some refresh button, just because its 3:30pm on Friday 13th... anytime not just in an event handler).

OK to call it from your parent window. At some time your parent window created a reference to the child window to show it (somewhere you have in youre code childwin mychildwin = new childwin(); mychildwin.show();

in your parent form button click event handler you need to code the following line
mychildwin.LoadDataGrid();
The important point here is that mychildwin is an INSTANCE of the childwin form and it is the SAME instance as the one that is showing currently. So you have to keep that instance in memory somewhere. Depending on how you called the childwin in the first place you have a few options: it could already be in your parents forms controls (if it was a subform, an mdi child etc.) or …

f1 fan 16 Posting Whiz in Training

the command name property could be used in your case but it is a bad habit to get into. The command name property is used when the button is used inside something like a datalist. You can have many buttons in various templates and they will want to do various things (such as Edit, cancel, update etc). The parent control (eg the datalist) handles these controls not the page so you have to tell the parent what type of command it is (hence commandname = "edit" or commandname = "update") and you have an event handler for the parent control in your code. As there are multiple versions of this button in a datalist control you might need to pass extra info to the event handler - this is where the commandargument comes in. The concept is the same as calling a method and passing in parameters.
So stick to the rule that command name = method name and command argument = parameters. So you can pass parameters even though you dont need a method name in this case as the handler is already named in the onclick property.

As for the code my vb is very rusty but i will try

protected sub SeatButton_Click(object sender, EventArgs e) handles Seatbutton_click

Dim theButton as Button  = Ctype(sender, Button) ' now you have the button that was pressed
Dim theSeat as string  = theButton.CommandArgument; ' now you have the seat number

' either store it in the session and the …
f1 fan 16 Posting Whiz in Training

Ok now i am totally lost. Your initial post had c and C and d and D but now you say there is no C or D? Your initial post also said if c is true to skip B but now you are saying if c is true to do B? Lets start again. I am with you that A B E F are processes and c & d are flags. Where do they get set? does the whole thing repeat?

f1 fan 16 Posting Whiz in Training

I think i am with you now. i was confused between c and C and d and D. i take it A B C D E and F are some processes/functions etc. and c and d are flags?

In which case my pseudocode needs a minor modification i think

A
if not c then B
if not d
{
   if not c then C
   D
   E
}
F
f1 fan 16 Posting Whiz in Training

I think we both got confused. I wasnt too sure what A B C etc meant. Are they states in a state machine? Or just processes? also do they run though the flow once or keep repeating? I thought they might be function calls or something . So the if not c then c meant if your c flag hasnt been set then do c.

f1 fan 16 Posting Whiz in Training

Session state can be used to store anything you want between sessions for a user (remember it is for a user not the application - there is an application state for that). Session is usually used for shopping carts and things like that. What you have to remember with a session is that the data is sent back and forth with every request from your user, not just for a page, but EVERY page and postback while they are on your site. So as long as you remember that and clear out any session variables as you finish with them (much the same as you should with any variable you use) then you can use it as much as you like.

But if it is just getting information from a page then there is no need to use the session. So we are back to options 2 and 3 from my last post.

For option 2: lets say in b.aspx you had 2 variables you needed to pass back to a.aspx. All you need to do in your response.redirect is call Response.Redirect("a.aspx?value1=" + val1 + "&value2=" + val2, true/false); then in page load of a.aspx just get those 2 variables by doing the following string value1 = Request.QueryString("value1"); string value2=Request.QueryString("value2"); The trouble with this is it appends it to the url so people can see it (the downside of a GET) so you can use a POST instead which uses hidden fields. This is option 3.

In …

f1 fan 16 Posting Whiz in Training

sorry should not be a while loop just another if statement

A
if not c then b
if not d
{
   if not c then c
   D
   E
}
F
f1 fan 16 Posting Whiz in Training

First 2 are correct. last pseudocode is wrong.
I think it needs to be something like

A
if not c then b
while not d
{
   if not c then c
   D
   E
}
F
f1 fan 16 Posting Whiz in Training

There is a limit and it is big from memory but i cant tell you off the top of my head. It is to do with the stacks heaps and the like. You really want to have that many nested loops that you are worried about a limit?

f1 fan 16 Posting Whiz in Training

i will give some pointers... i am not doing homework for you.
each button needs to be setup as follows:

<asp:Button ID="Button1" runat="server" OnClick="SeatButton_Click" Text="A1" CommandArgument="A1" />
<asp:Button ID="Button2" runat="server" OnClick="SeatButton_Click" Text="A2" CommandArgument="A2" />
etc etc

Then you need the one event handler which will handle all your seat buttons

protected void SeatButton_Click(object sender, EventArgs e)
{
Button theButton = (Button)sender; //now you have the button that was pressed
string theSeat = theButton.CommandArgument; // now you have the seat number

//either store it in the session and the database on some other buttons click (such as a "Book Now" button) or straight to the database on each click.. that depends on your requirements
}
f1 fan 16 Posting Whiz in Training

I have a feeling that something has set iis to look for default.aspx as the start page, or vs has been told to do the same. Did you have a default.aspx in there at one time? in your solution explorer right click on your home.aspx and click on set as start page. That will make sure that vs is correct. if you just opened a web browser and typed in the path there does it still happen? (I assume you have tried this).
Couple of other pointers outside of this. why are you using windows authentication and then implementing a login box and roles in a sql database? that usually implies forms authentication. Also, my vb is rusty at best and it may be more forgiving than c# but in c# you have to cast anything from the session before using it, otherwise it is just an object type and your <> wouldnt work.

f1 fan 16 Posting Whiz in Training

for post #14 -Which part didnt work? There is no mention of oledb in that code. If you just want to test the code then replace the first line int row = Toprow() with int row = 0 for now.
Which line is failing?
post # 11. What is the problem? What error are you getting?

for(int i=0;i<=3;i++)
{
double.Parse(split[i]);
}

is ok. The only problem with it is that there may not be values in the array. I would do for(int i=0; i < split.length; i++) or if the length is greater and you only want the first 4 then do a test to make sure each exists before the parse. The only other way it would fail would be that it is not a number. Error handling comes in here. Always always (always^1000) check your variables before performing anything on them.
Post #15 There are a number of ways. Always the best way is using an MVC pattern (Model View Controller) but i suspect in your case you dont have the time to learn and implement this. Though i recommend you make it your #1 priority when you finish this.
If the parent has the dat file then i would make a property (internal set if you can) in the child form that takes the datatable we created (or whatever you have made the grid source to be). Then in the child form on the set for the property just call the grid …

f1 fan 16 Posting Whiz in Training

Which version of VS are you using? Is the app hosted in IIS? Have you made changes there? What "Changes" did you make just before it stopped working?

Something is set in VS i think to make it start up looking for default.aspx but need to know which VS you are using first

f1 fan 16 Posting Whiz in Training

did you download the sample or copy his text? I just looked at it and the text was only a small part to illustrate the complex part of the paint event. Download the whole code sample and the TopRow function will be in there. I suspect it is grabbing the co ords of the column headers and starting under there for the paint.

f1 fan 16 Posting Whiz in Training

I am getting an apache server DoS attach everytime i open this post so beware. IT is only this post not the forum

f1 fan 16 Posting Whiz in Training

We can look at the 2d arrays later. Your code is almost there.
First, with your columns if you know they are going to be doubles then set the column data type as a double too.

Finally at the end instead of your line myDataSet.Tables["Table 1"].Rows.Add(split); use the following

DataRow theRow = myDataSet.Tables["Table 1"].NewRow();
theRow["X value"] = (decimal)split[0];
theRow["Y value"] = (decimal)split[1];
theRow["Vorticity"] = (decimal)split[2];
theRow["Stream Function"] = (decimal)split[3];
myDataSet.Tables["Table 1"].Rows.Add(theRow);

But thats just better code... your main problem is you didnt bind the dataset to the grid!!! Easy to miss but causes a problem after so much coding huh.

MyGrid.Datasource = myDataSet.Tables["Table 1"];

or MyGrid.DataMember = "Table 1";
myGrid.DataSource = myDataSet

If you use the second option always set the datamember name before binding the datasource otherwise you will bind twice and waste performance

Hope that gets you going.

However, i still think you could have just called myDataSet.SaveXML("mydatfile.dat")
then all you have to do is create a dataset, then call myDataSet.ReadXml("mydatfile.dat") and then bind it straight to the grid, no reading, no stream writers and readers, no anything but 2 lines of code.

You fill the table in the first place much the same way column by column .. row by row but that is the same as the dat file, only i suspect it will be easier too.

Let me know how you get on

f1 fan 16 Posting Whiz in Training

My mistake... rusty vb code knowledge with the Nothing keyword.
However i think i found his overflow problem. The randomizer is set to vary between 0 and the collection count. Shouldnt it be the collection count -1? As the next line is using the randomizer's result to index the collection

f1 fan 16 Posting Whiz in Training

Yeah. I usually make use of foreaching through the keyvaluepair. But that is why i subclassed the generic dictionary so i could do what you wanted. I basically took the keys and values collection and copied them to an array and indexed it that way. I also wrote an append method to add from another list/dictionary into that one by passing it in. It got messy but i needed the key value pair more than anything so the list was out

f1 fan 16 Posting Whiz in Training

oops i didnt realize they wanted it in dd/mm format not mm/dd format... just flick round the regex parts for days and months

f1 fan 16 Posting Whiz in Training

Ahhh my bad. Been using 2.0 for too long i guess :)
I still dont recommend a try catch (and am going to look into the tryparse as it is expensive to use try catchs.

In that case write a simple utility (I have them for integers, decimal etc) that uses regular expressions to validate the date

Regx.ValidationExpression=@"^(([1-9])|(0[1-9])|(1[0-2]))\/((0[1-9])
|([1-31]))\/((\d{2})|(\d{4}))$";

if it is a match then it is a date and so can perform quickly the day is valid for the month. It will still be a lot quicker than try catch blocks

f1 fan 16 Posting Whiz in Training
dbtaccessRow = Dsaccess1.dbtaccess.FindByrnumber(rnumber)
If dbtaccessRow.IsUsernameNull = True Then

dbtaccessRow is null if there are no records matching in the db so before in between those two lines you need to check if dbtaccessRow is null

f1 fan 16 Posting Whiz in Training

64 combo boxes???? You sure?
My VB is rusty sorry (I am a c# person but it is the same in .net other than syntax mainly) so i will give you the pseudocode.
On the combo2 selected index event handler do a Select Case statement for each value possible and depending on the value populate the correct textbox with the combo1 text.

eg

Case "Phones":
TxtPhones.Text = Combo1.Text

Case "Moves"
TxtMoves.Text = Combo1.Text

The same applies with combo4 and use combo3 text for the textbox

Does that help?

f1 fan 16 Posting Whiz in Training

Yeah i have been down a similar path (though i still used dictionaries but subclassed them) and used serialization and .net remoting instead of web services just to get round some issues. Hopefully in the future it will be solved as i dont see the point of not being able to fully serialize something without exposing all your private properties.

f1 fan 16 Posting Whiz in Training

Doesnt the new .net come with SQL Express 2005 which is the new version of MSDE but much better? But as Plazmo said... what .NET thingy? Do you want to write asp.net pages? If so i would suggest you go to the ASP.NET forum here for some ideas.
You dont need anything other than the .net sdk to write apps or web pages... vs and others are just nice tools. Being the nasty cruel person i am i make all my new staff write at least one small .net app in notepad only! Then they appreciate their IDE more and dont rely on it (the number of people i have seen that think just because there are no squiggly lines in their code it must work is unbelievable!)

f1 fan 16 Posting Whiz in Training
Do
line = objRe.ReadLine()
If Not line = "" Then
objColl.Add(line)
End If
'txtWord.Text = txtWord.Text & line & ControlChars.NewLine

Loop Until line Is Nothing

line will never be nothing so will keep looping indefinately hence the stack overflow

f1 fan 16 Posting Whiz in Training

Thats not good programming and performance!
NEVER use try catch as validation! IT is huge performance overhead.
What is wrong with DateTime.TryParse????

f1 fan 16 Posting Whiz in Training

the dictionaries are not serialized as they are private. Serializers only work on public properties/fields and even read onlys have problem. In laymans terms for an object to deserialize it basically creates a new object and writes the values back to it. For an object to do this to another object then the fields/properties have to be public. If you have a read only field then you have to be able to fill it in the constructor.

Hope it helps
One messy way around this is create public properties but limit the changes of values in the property set method, but as i said it gets messy

f1 fan 16 Posting Whiz in Training

Ok it is easy and now i understand. The website in my signature is purely made up of code on the fly. Here are some options for you:
Create a panel or placeholder or other such component on your blank page where you want information to go.
On page load read the information from the database and create the relevent controls (labels, images, hyperlinks etc) and add them to the panel.controls. You can apply styles and everything in code just as you would with a normal asp server web control.
The asp.net engine will render the controls as normal. (The only difference you have made between on the fly and using the designer is that the IDE puts the code in the InitializeComponent method where as you have it in page load or some similar method, but the code is the same.
Using panels and other containers renders a <div> tag in html. It also means you can have anything you like in there and will be decided depending on data from the database at run time. Use this if you are not even sure what controls you will need at run time.
If you know what you need but not sure of their values until you get the data at run time then place the controls on there but fill their values from the database when you get the information.

Remember both cases you can apply clientside scripts on the fly …

f1 fan 16 Posting Whiz in Training

simple
ALWAYS write code AFTER the InitialiseComponent() call. The control does not exist until that code has completed. It is the code the IDE puts in to create the control and all the child controls on it.

Also, i dont know if it was just a mistake on the post but you should be inheriting from UserControl not Control.

f1 fan 16 Posting Whiz in Training

Just in case i had your question wrong, the formattiing can be done with css (preferred way) and you can make use of the Literal control and set its text to any html (I will post a tutorial soon on how to write hidden fields on the fly for third party use using literals)

f1 fan 16 Posting Whiz in Training

One line in my last post maybe misleading:

Then when the whole transaction is complete save the information in the session object

Should have said

Then when the whole transaction is complete save the information from the session object

f1 fan 16 Posting Whiz in Training

first of all what may be URGENT to you (ie your homework) is not urgent to us. Everyone feels their problem is #1 priority so please dont post as URGENT. My business and income is far more urgent than your homework. But we are here to help so here goes :)

First of all have one click handler for all the seat buttons. Secondly for each button append the seat number (A1, A2 etc) to the command argument property. On the button click handler grab the argument property and store it in a session object. Then when the whole transaction is complete save the information in the session object. I would recommend either an array or table as the session object.
I assume that:
1. You know about the commandargument property
2. You know about sessions
3. You know how to handle the same eventtype (e.g. buttonclick) from multiple instances in one handler
4. You know how to save information in a database

If you dont know any of those then shout and i will help

f1 fan 16 Posting Whiz in Training

Use the code. This is the whole point of asp.net. You build a webpage on the fly and the asp.net engine will then convert it to html to output to the browser.

Each requirement is different, but you can put any webcontrol on a webpage and give it a value or text (Depending on the control) at run time in page load or other methods. Placeholders, images, textboxes, labels, grids, datalists, the list is endless.

An example would be to give a label some value:

Label1.Text = DataRow1["label1text"].ToString();

Or you can bind in the markup using <%# Eval("columnname", {optional format}) %> tags

f1 fan 16 Posting Whiz in Training

Thats a whole different scenario and requirements :) First it is better practice for a child not to know about its parent unless it is essential (in fact it is better if neither knows about each other - see the mediator pattern) but that is another topic all together.
From my understanding you have a form a.aspx and the user clicks a link to go to b.aspx where they fill in some information. When they have completed that you want to use the information back in a.aspx?
There are a number of ways to achieve this and you should not call a.method1 to do it. Use any one of the following:
1. use the session and add the values from b.aspx then when you are back in a.aspx get them out of the session and use them. Remember session means the data is going back and forth with every request and postback not just between a and b so clear any session variables you do not need as soon as you have finished with them
2 add the data to the response in b.aspx and get the data when you go back to a.aspx
3. add the data to hidden fields in b.aspx and get them in a.aspx when you get back (the difference between 2 and 3 is Get vs Post)
4. Put the data in a public property in b.aspx and register b.aspx in a.aspx then cast the context.header to b.aspx and …

f1 fan 16 Posting Whiz in Training

Sorry but i am a bit confused with your requirements. You say you have a 2d array but your example earlier shows a 1d array. There are thousands of different scenarios so instead of me guessing could you tell me what you are trying to achieve (which is different from saying how you are implementing it). I think you are taking data from somewhere, storing it, then reading it later to display it. I can then give you the best solution to implement it. I am still thinking the best way will be datasets and a grid but i am not sure of the information and how it got there in the first place.

Hope it makes sense.
Who inputs the data?
What is the data (in general not specifics)
Why were you using a 2d array? Was the data 2 tiered?

Let me know and i will get back to you later

f1 fan 16 Posting Whiz in Training

it looks tabular to me... it has to be to go into a grid or the data you show wont make sense. Create a data table with the columns you want (there appears to be 5 in yours) Create a dataset and add the table to the dataset. Then you just need to bind the grid to the datatable. To save it then call dataset.writexml(datfilename.dat) as it doesnt have to be an xml extension though i would recommend it unless there are other requirements why you have to have a .dat file. You can also encrypt it if you want but that is outside of this post.

When you need the data just create a dataset again and call dataset.readxml(datfilename.dat) and bind it to your grid again.

Very simple for offline storage and other non database storage.

f1 fan 16 Posting Whiz in Training

These few lines will allow you to email as html an aspx page from your site or in fact any web page you want (though i wouldnt recommend any with lots of scripts etc in it). It is very useful for email forms to customers etc from your site.

Personally I create an plainer version of the form just for email. I remove any menu functions and other things that are there as part of the website and are not useful in the email - but that is a personal preference.

I have also created an emailer class which i have simplified here for you

using System.Net.Mail;

public static class Emailer
{
public static void SendEmail(string from, string to, string subject, sting body)
{
SmtpClient smtp = new SmtpClient("hostname");
MailMessage email = new MailMessage(from, to, subject, body);
email.IsBodyHtml = true;
smtp.Send(email);
}
}

Now to send the page. Remember it can be any page and so you can do any codebehind processing first that you wish. In essence we call Server.Execute which runs the page as if it were in a browser, but without opening the page in the browser for the user to see. The lines of code are simple as follows:

using System.Net;
using System.IO;

////*** somewhere in an aspx page - preferably a different one to the one you are emailing but doesnt have to be******
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Server.Execute("theaspxpage.aspx", htw);
//the page has now processed and the …
f1 fan 16 Posting Whiz in Training

I have also found some problems with some developers hard coded the framework they developed against when it came to checking for the framework. I had a case recently where i have 2.0 on my pc but the app insisted i installed 1.1 so i binned it.

f1 fan 16 Posting Whiz in Training

you can set the focus method for the tab control. But i suggest that the page is reloading or setting focus to the first tab everytime in code or you are rebinding it each postback? Try the if (isPostback) to set the control or not as the case may be

f1 fan 16 Posting Whiz in Training

Sorry, i am not doing your work for you. But yes it is possible. Depends if you are talking to exchange or not on how you go about it. You can use the office tools for visual studio (especially the 2005 edition) and also can use CDO objects to talk to exchange etc.

Basically everything in outlook is an object and therefore you can talk to it

f1 fan 16 Posting Whiz in Training

ooops .. sorry .. lost my / on my closing code tag in the last post

f1 fan 16 Posting Whiz in Training

If you want to just use the default culture of the user then you can get it from the Request. Then set the thread culture to that culture. Doesnt give the users the choice though.

Thread.CurrentThread.CurrentUICulture = 
new CultureInfo(Request.UserLanguages[0].ToString());