How to create DSN in SQLServer

4
How to create a database in SQL server ? Open SQL Server Click on database icon . Right Click po pmenu will app ear choose new data base. A window will app ear here give the name of your database (eg.Student_db) and click OK. Then you will f ind the student_db will be added under datab ase directory. Select St udent_db then double click . You will find more directory are there , select table and right click and choose NEW Table Now here enter two fields user_name varchar(20) and password varchar(20) Save the table as login . How to create DSN in SQLServer ? Go to Start control panel Administrative tools ODBCclick on System DSNClick on ADD crea te new DSN window will Appear on that window Selec t SQL Server Click Finish A new window will prompt Enter the name of the DSN (eg Student_dsn) Leave the description box empty Go to next bo x enter the name of your SQL Server Connectio n like(eg. AF2 \SQLEXPRESS) Note: start your Sql server . copy the server Name and paste (this name is required) When you fill al l the information t here click on next button. Now your in different tab You w ill find Message like How should SQL Server verify the authentic ity o f th e log in I D? “ Choose window NT authentication using N etwork login ID Then click on next In this window choose the default database that you have created in SQL Server from the Combo box.

Transcript of How to create DSN in SQLServer

Page 1: How to create DSN in SQLServer

8/7/2019 How to create DSN in SQLServer

http://slidepdf.com/reader/full/how-to-create-dsn-in-sqlserver 1/4

How to create a database in SQL server ?

Open SQL Server

Click on database icon .

Right Click popmenu will appear choose new database.

A window will appear here give the name of your database (eg.Student_db) and click OK.

Then you will find the student_db will be added under database directory.

Select Student_db then double click .

You will find more directory are there , select table and right click and choose NEW Table

Now here enter two fields user_name varchar(20) and password varchar(20)

Save the table as login .

How to create DSN in SQLServer ?

Go to Start → control panel →Administrative tools → ODBC→ click on System DSN→

Click on ADD → create new DSN window will Appear on that window Select SQL Server

→Click Finish

A new window will prompt

Enter the name of the DSN (eg Student_dsn)

Leave the description box empty

Go to next box enter the name of your SQL Server Connection like(eg. AF2\SQLEXPRESS)

Note: start your Sql server . copy the server Name and paste (this name is required)

When you fill all the information there click on next button.

Now your in different tab

You will find Message like “ How should SQL Server verify the authenticity of the login ID? “

Choose window NT authentication using Network login ID

Then click on next

n this window choose the default database that you have created in SQL Server from the Combo bo

Page 2: How to create DSN in SQLServer

8/7/2019 How to create DSN in SQLServer

http://slidepdf.com/reader/full/how-to-create-dsn-in-sqlserver 2/4

Page 3: How to create DSN in SQLServer

8/7/2019 How to create DSN in SQLServer

http://slidepdf.com/reader/full/how-to-create-dsn-in-sqlserver 3/4

Create a new project in net beans with the name login .

Then double click on project .

You will find source package, Test package….etc directory

Double click on source package you will find login directory ,select login and right click a new box wppear choose new frame and insert the the item according to picture shown below.

Then right click on insert button and click event choose action performed

Page 4: How to create DSN in SQLServer

8/7/2019 How to create DSN in SQLServer

http://slidepdf.com/reader/full/how-to-create-dsn-in-sqlserver 4/4

nside that area type following code :

String user = jTextField1.getText();

String pwd = jTextField2.getText();

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:manish");

//String qry = "";

PreparedStatement stmt = con.prepareStatement("insert into login values(?,?)");

stmt.setString(1,user.toString());

stmt.setString(2,pwd.toString());

stmt.executeQuery();

con.close();

}catch(SQLException e){

e.printStackTrace();

}catch(ClassNotFoundException e){

}

Then go to build and select clean and build main project .

There after run the program.