f1 fan 16 Posting Whiz in Training

90% of what you do in C# (or any OO language for that matter) is in functions.

I am not sure exactly what you are asking though - I know you are new to C#. You ask if you can put some repetative code in a function and call it over and over instead of coding it everytime. But coding it every time is writing a function every time and calling that code is calling a function - so it is the same principal in c#.

If you could be a little bit clearer or give some small code of what you are trying to do I will give you a better answer to get you on your way. :)

f1 fan 16 Posting Whiz in Training

OK
You can get webdeveloper express which is free and makes it a lot easier.
the code below has a grid view which lets me list, edit and delete items in the grid (it could select too but i have no need of that in this example).
grid views dont allow news rows so i use a details view (below it) which is in default mode of insert.
Both are bound to the sqldatasource which you see below them. In my case i have the connection string elsewhere in my app which it knows to go find by the <%$ ... %> tags. You can use stored procs etc but i included this code for you to see
Hope it helps you

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
        AutoGenerateColumns="False" DataKeyNames="aID" DataSourceID="SqlDataSource1" Caption="Collections" Width="300px">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
            <asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
        </Columns>
    </asp:GridView><br /><br />
    <asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateRows="False"
        DataKeyNames="aID" DataSourceID="SqlDataSource1" DefaultMode="Insert" Height="50px"
        Width="300px" Caption="Add New Collection">
        <Fields>
            <asp:BoundField DataField="aID" HeaderText="aID" ReadOnly="True" SortExpression="aID" Visible="False" />
            <asp:BoundField DataField="CollectionName" HeaderText="Collection Name" SortExpression="CollectionName" />
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
        ConnectionString="<%$ ConnectionStrings:CHComConnectionString %>" DeleteCommand="DELETE FROM [Collections] WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName"
        InsertCommand="INSERT INTO [Collections] ([aID], [CollectionName]) VALUES (newid(), @CollectionName)"
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT [aID], [CollectionName] FROM [Collections] order by [CollectionName]"
        UpdateCommand="UPDATE [Collections] SET [CollectionName] = @CollectionName WHERE [aID] = @original_aID AND [CollectionName] = @original_CollectionName">
        <DeleteParameters>
            <asp:Parameter Name="original_aID" Type="Object" />
            <asp:Parameter Name="original_CollectionName" Type="String" /> …
f1 fan 16 Posting Whiz in Training

use the formview control and bind it to a datasource control which is configured to access your database.
If you use VS2005 they are there and very simple to setup (follow the wizards). Drop a form view onto your page, where it says datasource use the drop down to make a new one and follow the wizard to configure the datasource to do selects, updates, inserts and deletes to your database.

When it is all done and working properly you will be able to see the code it created and understand what it did and then you can roll your own at any time.

The datasource is a powerful tool, especially the object datasource if you are using multi tier applications

f1 fan 16 Posting Whiz in Training

if the texbox was bound to the database and there is no value then num1 num2 etc. is empty or null, neither of which will parse to a double to be able to be added. You need to do a test to see if they are null or empty and make thier value 0.
The easiest way is to set the value to 0 when you pull it from the database (either set the value to 0 or put 0 in its place in the stored proc). Or you can do it just before you do your sum.

f1 fan 16 Posting Whiz in Training

when do you call CalcColumn()?
You havent quite grasped the concept which is where you are going wrong but thats why we are here :)
Are you using a strong typed dataset to get your data? You dont want to add the unbound column to the grid in a grid editor (this isnt an unbound grid column its an unbound datacolumn - there is a big difference in the two).

Wherever you get your dataset from... before you pass it to the grid to bind it, thats where you need to put those lines of code.

It will work, its just you arent calling it at the correct time (if at all).

So you need to
1. Get your dataset from the database
2. Add the unbound column with the expression to the datatable
3. Bind it to the grid.

If you have a strong typed dataset then you can add the column there and even set the expression there. IF not then you have to use those few lines of code.

Try and grasp this concept (unfortunately they are similar names so everyone gets confused in the beginning). You have a database which has tables and columns. You have an ado.net dataset which has tables and columns (these can map one to one but do not have to! thats very important.. it was done deliberately to give us more power... old ado before ado.net would …

f1 fan 16 Posting Whiz in Training

database1Dataset.Columns.Add(Column1);
that line is incorrect
Cannot add a column to a dataset... need database1dataset.Tables["sales"].Columns.Add(Column1); if sales was the table name

f1 fan 16 Posting Whiz in Training

you create an unbound column in the sales and use the Expression property whose value is quantity*price (assuming those are the two column names). Only create bound columns if you want data saved in the database or pulled from the database (you could have created the column in your query and pulled it into your grid but when a new row is added the total wouldnt automatically update - whereas it does with an expression).

f1 fan 16 Posting Whiz in Training

sms is complex and not free but can be done. There are gateways which you can setup with your provider. There is a way to do it via email and is usually mobilenumber@carrierssmsmail.tld i know them for usa but not for uk. I would think vodafone would be mobilenumber@vodafone.net.uk but dont quote me on it.

f1 fan 16 Posting Whiz in Training

oh ok i thought you were trying to get the MAC and other things too.

your dns is in the form xxx.xxx.xxx.xxx

so there is a clue. it is DELIMITED by the . (period)

so instead of your textbox1.text = h.AddressList.GetValue(0).ToString

dim ipfull as string = h.AddressList.GetValue(0).ToString

dim ipsplit as string[] = ipfull.split(".".tochararray[])

you now have an array in ipsplit.
textbox1.text = ipsplit[0]
textbox2.text = ipsplit[1]
textbox3.text = ipsplit[2]
textbox4.text = ipsplit[3]
all done

f1 fan 16 Posting Whiz in Training

use System.Management classes to do it. Writing WMI queries. Have a look at it and if you are stuck let me know and i will give you some code.

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

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

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

Just one quick one on stored procedure names... dont prefix a stored procedure with sp_ use anything but this as when you call a stored procedure SQL Server looks at the name and if it starts with sp_ it will go to the master database first, do a search for the stored proc and only when it fails will it then look in your database. It can be a big performance hit.

f1 fan 16 Posting Whiz in Training

so you want to auto refresh the page at set times?
Best way to do it is to put it in the META tag. It is the same technique as an auto redirect to another page, only this time you are reloading your own page.

You can either code this in the markup when you design it or you can add it later in code when you want it.

in code you need to add the following line
Response.Write("<Meta http-equiv='REFRESH' content='20;URL=mypage.aspx' />");

and in markup you just need
<Meta http-equiv='REFRESH' content='20;URL=mypage.aspx' />

the 20 means 20 seconds, so put your own time in there. It is as simple as that

f1 fan 16 Posting Whiz in Training

I agree. However should you need to pause the thread while another thread completes then use thread.sleep(timetosleep)

f1 fan 16 Posting Whiz in Training

are you talking about a popup window or a whole new webpage/site? if you need to do a new browser window with a webpage then in the link that you have you need to set the target="_blank"

if you want to just do a popup window then the best way is a javascript:window.popup() script on the client. You can do this a few ways - code it in the source on the aspx page, have a function in a script file somewhere (preferable to script in the html) or call the ClientRegisterScript in your code behind.

f1 fan 16 Posting Whiz in Training

I am slightly lost but i think i know what you mean.
In design view in all VS (2002, 2003 and 2005) you can click the events icon in the properties box (normally you have it in properties view to fill in the name, text, color etc.).
Switching to events view shows all the events available (key-press, mouseover, click, doubleclick etc). By double clicking the event name you want, VS will automatically put the code block in (as it did with the default code block for the control but this time the event you chose).
The will put that code block in the file it defaults to (normally your default .cs file partial class in 2005). If you have created a partial class yourself (say JUST for event handling - and on larger objects it is a good idea) then unfortunately VS does not know where you want things so have to manually add the event handler in code typing in

object.eventname += new Eventnamehandler (event signature)

When you type the += VS will automatically ask you in intellisense if you want to add the default handler signature stuff.