How to connect sql to studio

 How to connect sql to studio

 

Name of server:-LAPTOP-1B3T3LF5\SQLEXPRESS

 

Step1 :- go to server explores then right click on data connection.

STEP 2 : RIGHT CLICK DATA CONNECTION

STEP 3 : CLICK ON ADD CONNECTION

STEP 4 : SELECT SQL SERVER

STEP 5 : PASTE SERVER NAME

STEP 6 : SELECT DATABASE NAME 

STEP 7 : OK

 

 

 

 

 

 

Ø How to get sql sever connection strings.

Drag and drop table and then same configre method

 

Ø How to get database connection string in class and object.

Ø pth

Data Source=LAPTOP-1B3T3LF5\SQLEXPRESS;Initial Catalog=college;Integrated Security=True

 

Ø How to create class

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Data.SqlClient;

 

/// <summary>

/// Summary description for student

/// </summary>

public class student

{

    SqlConnection con;

    SqlCommand com;

    SqlDataReader dr;

    public string connection()// return to aspx page

    {

        string stt = @"Data Source=LAPTOP-1B3T3LF5\SQLEXPRESS;Initial Catalog=college;Integrated Security=True";

        con = new SqlConnection(stt);

        con.Open();

 

        return stt;

 

    }

}

 

Ø Q.Access class inside the aspx page:-

Ans :- Using object

 

 public string Submitdata(int ROLL_P, string NAME_P)

    {

        connection();

 

        string inst = "INSERT INTO DEMO VALUES (@ROLL1,@NAME1)";

        com = new SqlCommand(inst, con);

 

        //PARAMETERS

 

        com.Parameters.AddWithValue("ROLL1",ROLL_P);

        com.Parameters.AddWithValue("NAME1", NAME_P);

 

        com.ExecuteNonQuery();

 

        return inst;

       

 

    }

 

HOW TO CLASS IT

 

 // accessing the class  

 

        student s1 = new student();

 

        // method accessing

 

        s1.Submitdata(int.Parse(TextBox1.Text),TextBox2.Text );

 

        Response.Write("data submit");

    }

Comments

Popular posts from this blog

ViewState for state management

Store procedure Data Base handling (procedure_insert).

Database joining