Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2004, 03:04 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Login WinForm in C#

Hi..
can u give me a favor??

this is my sample coding..

private void btnLog_Click(object sender, System.EventArgs e)
        {
            if(SahForm()==false)
            {
                return;
            }

            InLogin();
        }

        private void InLogin()
        {
            string ConnStr = "server=localhost;database=Admin;trusted_connectio n=true";
            string MySQL = "SELECT UserName, UserPass from Login WHERE UserName = '+ txtLog.Text + '" +
                          "AND UserPass = '+ txtPass.Text') ";

            SqlConnection MyConnStr;
            SqlCommand MyCmd;
            SqlDataReader MyDR;

            MyConnStr = new SqlConnection(ConnStr);
            MyCmd = new SqlCommand(MySQL,MyConnStr);
            MyConnStr.Open();
            MyDR = MyCmd.ExecuteReader(System.Data.CommandBehavior.Cl oseConnection);

            if(MyDR.Read())
            {
                MyDR.Close();
                MyConnStr.Open();
                MyDR = MyCmd.ExecuteReader(System.Data.CommandBehavior.Cl oseConnection);

                Sistem sist = new Sistem();

                //this.Hide();
                sist.Show();
            }
            else
            {
                MessageBox.Show("ERROR");
                MyDR.Close();
                MyConnStr.Close();
            }
        }

        private bool SahForm()
        {
            if(txtLog.Text == "" && txtPass.Text == "")
            {
                label4.Visible=true;
                label5.Visible=true;
                MessageBox.Show("Please enter Admin's ID and Password", this.Text);
                txtLog.Focus();
                return false;

            else
            {
                return true;
            }
        }

but it'll return an error after we input the Admin's ID and Password. The error look like this...


An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

Additional information: System error.

So, please anybody help me.. =(

 
Old September 3rd, 2004, 09:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This forum is for ASP.NET programming, and more specifically for the book "ASP.NET Website Programming, Problem - Design - Solution". Please post your message to the right forum.

Eric





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing value from winform to crystal report shai Crystal Reports 0 January 20th, 2007 05:19 AM
Loading a WinForm using at Runtime ashu_from_india General .NET 0 October 3rd, 2006 04:04 AM
WinForm and Sharepoint natarajan_ve .NET Web Services 0 July 28th, 2005 05:35 AM
Disposing a WinForm in Excel Bowmangotti VB.NET 2002/2003 Basics 0 October 5th, 2004 10:13 PM
Add ComboBox into DataGrid(WinForm) shiju VS.NET 2002/2003 1 November 1st, 2003 11:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.