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

Recommended Answers

All 8 Replies

What is the topic of your project?

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..

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

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();
    }

thanks for helping, it was relly halpfull

my pleasure :)

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??

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.