-1

hey, i meed to do a school project in asp.net and i am relly bad,
i need to connect database to a login (i use visual 2008 and sqlserver 2005),
this is the start poin, pls help me whith this, thanks

4
Contributors
8
Replies
9
Views
6 Years
Discussion Span
Last Post by crishjeny
0

This should be a Mtmattiut tabs, and its have a login for the ticher, onli one ticher, one topik and one tab, i bild the DB, and i dont know how to Combine it..

0

hi, please add the follwoing code in you aspx.cs page.
Step 1 : Add Namspace

using System.Data.SqlClient;
using System.Data;

Step 2 : Make Sql connection.
Step 3: Pass the sql command to database

//Write this code to create Sql connection.
SqlConnection conn = new SqlConnection("Data Source=servername;Initial Catalog=DatabaseName;User ID=sa;password=pwd;Integrated Security=True"); 
SqlCommand cmd = new SqlCommand("Write your sql query here eg. select * from Table name");
con.Open();
DataSet ds = new DataSet(cmd,con);
SqlDataAdapter da = new SqlDataAdapter();
da.Fill(ds);
con.Close();

i hope this should work

Edited by abelLazm: n/a

0

for login, try these codes

protected void Submit1_ServerClick(object sender, EventArgs e)
    {
        con.Open();

        try
        {
            if (txtUsername.Value == "" && txtPassword.Value == "")
            {
                msg.Visible = true;
                msg.Text = "Please enter your Login details";
            }
            else
            {
                string reading = "select UserID, Password from DBUser where UserID='" + txtUsername.Value + "'and Password='" + txtPassword.Value + "'";
                SqlCommand selectcmd = new SqlCommand(reading, con);

                bool x = false;

                SqlDataReader reader = selectcmd.ExecuteReader();

                while (reader.Read())
                {
                    x = true;
                    Response.Redirect("Login.aspx");
                }

                if (x == false)
                {
                    msg.Visible = true;
                    msg.Text = "Invalid Username/Password";
                }
            }
        }

        catch (Exception)
        {
            msg.Visible = true;
            msg.Text = "Registeration failed!";
        }

        con.Close();
    }

Edited by pinkygirl: n/a

0

thanks for helping, it was relly halpfull

Edited by miwa1: n/a

0

hey, i have 2 listbox, i whant that when i press on one topic on the first list box, in the secend listbox will show the sub topic, how i can do this??

0

hey, i meed to do a school project in asp.net and i am relly bad,
i need to connect database to a login (i use visual 2008 and sqlserver 2005),
this is the start poin, pls help me whith this, thanks

Your question is totally fundamental.So,if u have no database,you can create your database from server explorer.

You can choose any field like no,name,city,pincode number.

you can give it a primary key, auto increment.

take one web page and than use login control from toolbox

Edited by Narue: Snipped fake signature

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.