[RESOLVED] C# Project help
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: [RESOLVED] C# Project help

  1. #1
    Join Date
    Sep 2012
    Posts
    14

    [RESOLVED] C# Project help

    hello all,


    im really new into programming and was wondering if someone could give me a hand, i have looked online, forums, videos etcand cant seem to get my answers from these and get confused and lost.


    basically i wanna make a application to do the following (best way i can explain it sorry)

    machine 1 = "Client", person inputs data, receives data, signs in, registers, and various other things

    Machine 2 = "Server", receives data from machine 1 and machine 3 and saves to machine 3, receives data from machine 4 sends to machine 1 on request

    Machine 3 = "Databases", stores the databases for client user info

    Machine 4 = "Server2" robot gathers various information from databases from within machine4 sends to machine 2


    this is my basic idea, and dnno how and where to start, im using visual 2012 and sql 2012


    appreciate any help i can get


    Regards


    Dean

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: C# Project help

    Write the client apps with Windows Forms or WPF.
    Write the server app as a WCF service.
    The WCF service would read and write its data to a SQL database.
    The Robot app interacts with the WCF service (which in turn reads/writes to the database).
    The WCF service can use a 'Dual' interface to send data to the clients.

  3. #3
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    hey thank you for your reply. i have now written login form, registration form, error forms, databases etc, now my next question is how do i send data from the registration form to the wcf server which in turn will send to the db, and when logging in how will it read the username and pass from the wcf server

    sorry still getting my head around this and reading tutorials and watchong videos on youtube, but cant find this specific thing

    thanks in advance

    Dean

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: C# Project help

    try searching bing or google for "wcf service tutorial video"

  5. #5
    Join Date
    Jul 2012
    Posts
    90

    Re: C# Project help

    Sorry for being so late to the party, but from the descriptions above it sure sounds an awful lot like a classic internet/intranet application:

    Machine 1 = "Client" (browser on client's workstation)

    Machine 2 = "Server" (Web server)

    Machine 3 = "Databases" (nuff said)

    Machine 4 = "Server2" (back-end processing)

  6. #6
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    hey will look for this now thank you,

    basically ill try to explain bit better as to what im wanting to do;

    for example, if wanted to do online shopping,

    i would load up my client (can do it off line as well as some features will be available offline) and sign up or login,

    this will then talk to machine two which will retrieve data from the databases to make sure the informaion input is correct.

    i then search for e.g. cheese, i hit search on client and this sends reques to machine 2, which has data sent to it on a reqular basis to keep it updated from machine 4 machine 5 machine 6

    say machine 4 = tesco
    machine 5 = sainsbury
    and machine 6 = asda

    then the details would be sent to my machine 1

    but is nothing to do with web servers machine 4 would be using programme like sage etc i just need machine 2 in place, so it has a bit of protection if anyone tries to intrude

    Deano

  7. #7
    Join Date
    Jul 2012
    Posts
    90

    Re: C# Project help

    In light of the more detailed description, I'd have to agree with Arjay's recommendations.

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: C# Project help

    To expand on the design I mentioned earlier...

    The WCF service is really the 'hub' of the architectures. Clients making queries, and/or receive notifications talk to this service. Also machines making updates to the database (machines 4, 5, and 6) also talks to the WCF service. The important thing is no machine other than the WCF service accesses the database directly.

    For notifications back to the client(s), you have two choices: 1) each client can use a dual WCF interface to receive a 'callback' notification, or 2) each client can poll the WCF service periodically for new updates.

    If you are going to implement this, it actually sounds harder than what it is. Sure, there is a bit of a learning curve involved, but tackle a bit of the program at a time. Learn how to write a WCF service and host it (with stubbed out dummy data). Learn how to connect to the WCF service with a client. Later replace the stubbed out data with calls to a database, and so on.

    In terms of WCF services, read my 'Tray Notify' article series in my subject line. That shows a bit on WCF services, hosting of them inside a Windows Service, and using dual interface.

  9. #9
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    hey thank you so much for all the help, will start studying and trying this nhow, will keep u updated on progress and no doubt with more silly questions

    thanks again

    Dean

  10. #10
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,219

    Re: C# Project help

    Check out my article series - Tray Notify listed in the "My Code Guru Articles" link in my signature line.

    It outlines some WCF service basics including how to host a WCF service in a Windows service and using a dual interface.

  11. #11
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    hey, thanks again, looked through the information and found few videos on youtube, looks alot more difficult and confusing than i anticipated, looks like will take me longer to do this than planned,

    putting project on hold while i research into it abit more

    Dean

  12. #12
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    from looking up and reading abit now, i have started to make this using windows forms which i have read is easier than wcf etc, so when i get the hang of it ill follow your directions above, i have created login screen, it work when i add data to db manually, now my problem is, when i register, it doesn save data to db, i have tried a few different codes, and cant get it going, this is what i have if anyone can help me please will be greatfull

    private void button1_Click(object sender, EventArgs e)
    {
    string connection = @"Data Source=COMPUTER\SQLEXPRESS;Initial Catalog=TestDB;User ID=**;Password=**";
    SqlConnection cn = new SqlConnection(connection);
    try
    {
    cn.Open();
    }
    catch (Exception)
    {
    MessageBox.Show("did not connect");
    }
    string username = textBox1.Text;
    string password = textBox2.Text;
    string sqlquery = ("SELECT * FROM Table WHERE Username = '" + textBox1.Text + "'");
    sqlquery = "INSERT INTO [Table] (Username, Password) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "')";

    SqlCommand command = new SqlCommand(sqlquery, cn);
    command.Parameters.AddWithValue("Username", username);
    command.Parameters.AddWithValue("Password", password);
    command.Parameters.Clear();


    it doesnt throw up any exceptions or errors

    Regards

    Dean

  13. #13
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    from looking up and reading abit now, i have started to make this using windows forms which i have read is easier than wcf etc, so when i get the hang of it ill follow your directions above, i have created login screen, it work when i add data to db manually, now my problem is, when i register, it doesn save data to db, i have tried a few different codes, and cant get it going, this is what i have if anyone can help me please will be greatfull

    private void button1_Click(object sender, EventArgs e)
    {
    string connection = @"Data Source=COMPUTER\SQLEXPRESS;Initial Catalog=TestDB;User ID=**;Password=**";
    SqlConnection cn = new SqlConnection(connection);
    try
    {
    cn.Open();
    }
    catch (Exception)
    {
    MessageBox.Show("did not connect");
    }
    string username = textBox1.Text;
    string password = textBox2.Text;
    string sqlquery = ("SELECT * FROM Table WHERE Username = '" + textBox1.Text + "'");
    sqlquery = "INSERT INTO [Table] (Username, Password) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "')";

    SqlCommand command = new SqlCommand(sqlquery, cn);
    command.Parameters.AddWithValue("Username", username);
    command.Parameters.AddWithValue("Password", password);
    command.Parameters.Clear();


    it doesnt throw up any exceptions or errors

    Regards

    Dean

  14. #14
    Join Date
    Sep 2012
    Posts
    14

    Re: C# Project help

    never mind got it sorted changed code to this

    string username = textBox1.Text;
    string password = textBox2.Text;
    string sqlquery = ("SELECT * FROM [Table] WHERE Username = '" + textBox1.Text + "'");

    sqlquery = "INSERT INTO [Table] (Username, Password) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "')";

    SqlCommand command = new SqlCommand(sqlquery, cn);
    // command.Parameters.AddWithValue("Username", username);
    // command.Parameters.AddWithValue("Password", password);
    // command.Parameters.Clear();
    command.Parameters.Add("@Username", SqlDbType.VarChar, 20);
    command.Parameters["@Username"].Value = textBox1.Text.ToString();
    command.Parameters.Add("@Password", SqlDbType.VarChar, 20);
    command.Parameters["@Password"].Value = textBox2.Text.ToString();

    command.ExecuteNonQuery();

    cn.Close();

    now how do i make it check to see if the username is already used as i can input the same one multiple times

    Dean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center