Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi Friends,
Can Anyone help me with Idea ? I am having an Default.aspx Page ( UI Page ) with four textbox and a button(Show in Excel) ? The Textbox are 1. ServerNameTextbox 2. DatabaseNameTextBox 3.UserNametextbox 4.PasswordTextbox . And My Need is If I give the servername,databasename,username,password values in the textbox and click the Button then I need to get all details about the database from sql server with table name, column name and column datatypes and bind this information in Excel ??
Posted

The problem is that you can't "show in excel" on the client directly: you can send the client an Excel file, but it's up to him if he wants to open it, save it or if he even has Excel installed.

You can use Excel in your code, but it will run on the Server, not the Client, so it production it won't be available for the user to view.
 
Share this answer
 
Hi Murugappan,

Use DatabaseName,Username and password to check the connection by passing it with connection string,
If connection is successful then use the below query to fetch the details about database
SQL
USE DatabaseName;
SELECT * FROM sys.objects WHERE type_desc LIKE '%FUNCTION%' OR type_desc IN ('USER_TABLE','SQL_STORED_PROCEDURE','VIEW') order by type_desc asc;

the above query will fetch all details that belongs to the Database given

If you want to fetch on category based then you can make use of the below queries
SQL
USE DatabaseName;
SELECT * FROM sys.tables
SELECT * FROM sys.procedures
SELECT * FROM sys.views
SELECT * FROM sys.objects WHERE type_desc LIKE '%FUNCTION%';

Once fetched you can export it into Excel using server side code.You can refer here[^] for this.
Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900