michael2009
asked on
How do i create an SQL viewer using ASP.NET in C#
Hi i'm a newbie to C# programming and i am trying to create an SQL command viewer same as ISQL * Plus using Visual Studio 2005 in C#
I have a database created using SQLDataSource which is called customer. It contains ID, firstname, surname, address. This is linked to a Gridview which display the information within the database.
Want i want is to bind the textbox some how to the database or Gridview so when the user type in any SQL command/statement via the textbox such as "SELECT firstname from Customer; or "INSERT INTO customer(firstname,surname ,adress) VALUES ('Alan','Smith','Boston') It will show the results in the Gridview.
However, i want some type of validation to ensure the SQL command entered by the user is correct and is shown to the user.For example In a form of an error message on the web page stating either correct or incorrect if they miss out the ; <-- (cant remember what you call it again)
I would also like to expand this by allowing the user to create a database using the text box and perform othe SQL statement such as SQL ORDER BY, SQL DELETE, SQL UNION,SQL GROUP BY etc
I have a database created using SQLDataSource which is called customer. It contains ID, firstname, surname, address. This is linked to a Gridview which display the information within the database.
Want i want is to bind the textbox some how to the database or Gridview so when the user type in any SQL command/statement via the textbox such as "SELECT firstname from Customer; or "INSERT INTO customer(firstname,surname
However, i want some type of validation to ensure the SQL command entered by the user is correct and is shown to the user.For example In a form of an error message on the web page stating either correct or incorrect if they miss out the ; <-- (cant remember what you call it again)
I would also like to expand this by allowing the user to create a database using the text box and perform othe SQL statement such as SQL ORDER BY, SQL DELETE, SQL UNION,SQL GROUP BY etc
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>SQL Viewer</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<span style="font-size: 10pt; font-family: Tahoma">Select only the firstname and address
from the table</span><span style="font-size: 10pt; font-family: Tahoma"><br />
<br />
Enter SQL Command below:<br />
</span><br />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Height="184px" Style="z-index: 103; left: 8px;
position: absolute; top: 72px" Width="504px" TextMode="MultiLine"></asp:TextBox>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:GridView ID="GridView1" runat="server" Style="z-index: 101; left: 8px; position: absolute;
top: 392px" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="Surname" HeaderText="Surname" SortExpression="Surname" />
<asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" Style="z-index: 102; left: 8px; position: absolute;
top: 272px" Text="Execute" />
<br />
<br />
Message to the user<br />
<br />
<br />
Results of the query<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Customer]"></asp:SqlDataSource>
</div>
</form>
</body>
</html>
ASKER
Many thanks for your reply. However i still need this done in asp.net C# a tutorial or the code maybe
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
praveenvenu thanks for that i'm examining the code and get back to you. I'm doing a task for work hence the reason i need the code
Microsoft SQL Web Data Manager
--------------------------
http://www.microsoft.com/DownLoads/details.aspx?FamilyID=c039a798-c57a-419e-acbc-2a332cb7f959&displaylang=en