Building A Generic Page "Query Analyzer" Like In Asp.net With SMO?
Mar 26, 2010
I'm build a web page in ASP.net is supposed to work just like Query Analyzer. It has basically a textarea to input the sql command, and an Execute button.I'm using SMO to execute the command in the database, as follows:
//Create object SMO
Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(new Microsoft.SqlServer.Management.Common.ServerConnection(oConn));
//To execute the command
server.ConnectionContext.ExecuteNonQuery(tbx_cmd.Text);
//OR
myDataset = server.ConnectionContext.ExecuteWithResults(tbx_cmd.Text);
The problem is that the textarea command can contain anything, from a stored procedure (with GO's statements) and any select command that return resultsets, just like Query Analyzer.But, if I have GO statements, I only can perform the query using ExecuteNonQuery method. If I use the ExecuteWithResults method, it raises errors because of the GO statements.And if I want the resultsets to be available, of course I can only use the ExecuteWithResults method. how can I do to execute the same command texts at the same time?
View 2 Replies
Similar Messages:
Jan 7, 2010
Is it possible to create my own query analyzer?The idea is the user just have to type their query in a textbox (SELECT only) then after pressing the execute button, records will be displayed in the page.If the user uses Insert, Delete or anything transactional, it will display msg that will prohibit the user executing the script
View 5 Replies
Aug 22, 2010
1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like
SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.
Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).
2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query
(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).
If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.
View 11 Replies
Jan 13, 2010
I have table having data like:
ID Date Name
1 1/1/2009 a
2 1/2/2009 b
3 1/3/2009 c
I need to get result something like...
1 1/1/2009 a
2 1/2/2009 b
3 1/3/2009 c
4 1/4/2009 Null
5 1/5/2009 Null
6 1/6/2009 Null
7 1/7/2009 Null
8 1/8/2009 Null
............................
............................
............................
30 1/30/2009 Null
31 1/31/2009 Null
I want query something like..
Select * from tbl **where month(Date)=1 AND year(Date)=2010**
Above is not completed query.
I need to get all the record of particular month, even if some date missing..
I guess there must be equi Join in the query, I am trying to build this query using Equi join
View 3 Replies
May 6, 2010
I am somewhat of a novice at ASP.NET, but have a lot of database experience. I want to build a web query interface to allow users to get data back from a database. The idea would be to choose various fields (I have about 20+ fields and 200,000 records in the database, and use either the checkbox, listpicker, radio, etc. to select the fields they want). Then the person could search by date, or search by greater than/less than statements in a particular field.
For example: the user could select: Temerature as the variable, and then Greater than and then enter a value and hit submit. I'd like the option to be able to include all the other fields from the table as well (maybe with a check box or something).
View 14 Replies
Aug 23, 2010
I have one SQL Query and it is working fine. Now, I want to access another table using One of the columns in this table.How can I access that value and How to put that in the existing SQL Query
View 4 Replies
Jan 15, 2010
Here is my table and data of these tables
Table name: Code
CID Code
1 abc
2 def
3 xyz
Table Name : Details
ID Name CID
1 a 1
2 b 2
Resultant Table:
ID Code Name
1 abc a
2 abc Null
3 def b
4 def Null
5 xyz Null
6 xyz Null
I nned to get all record from the code table and against each code I have to get all the rows from the details table, if some code have value their need value and if not then Null
View 1 Replies
Aug 20, 2010
I am having problems with a user control. I want my solution to have a separate project for holding my user controls.The main project can get a reference to this user control project and can import this user control dll into my main project.
View 3 Replies
Apr 4, 2011
I've setup an ItemTeplate like so in a GridView:
<asp:TemplateField HeaderText="Building">
<ItemTemplate>
<asp:Label
[code]....
View 1 Replies
Nov 25, 2010
I'm trying to create a control out of a class I found, and one of the overridden functions is the following:
protected override void PerformDataBinding(IEnumerable data)
However, when I try to build the control I'm getting the error as shown in the subject. I've tried searching, and it seems the signature for the original function matches the one I have, and all other solutions I've seen uses the same signature.
View 3 Replies
May 17, 2010
I have seen some examples on other sites , but since im not familiar enough with DirectoryInfo and Files from the System.IO namespace, i dont know how to change it to fit my needs. So i found a very simple example that works, but i have some questions.
Here is the code i found:
[Code]....
This works great and lists the files in my root directory.
#1 - What i need to know is how to accomplish the same thing but in a format i can control, this code simply displays the files at the top of my page and pushes everything down. So does anyone know of a good and simple tutorial written in C#?
#2 - I also need to be able to setup the code so that certain files within the directories are not displayed, as in the code behind files and other files to be determined by the business.
View 2 Replies
Oct 30, 2010
What is the difference between generic and non-generic collection?
View 1 Replies
Feb 23, 2011
I need to create a generic action page that accepts post data from an html form. The server is running asp.net 2 on windows 2003 iis6.
I don't want the page to post back to itself, but that redirect to another page. How do I create the page that accepts the data from another page? Not really sure where to start here
View 1 Replies
Mar 25, 2011
My intention is to give the user a flexible user control on a master page that does the following:
When navigating, a child page will pass the URL (with querystring) and PageTitle to the user control. The user control will take those two parameters and insert them as a "breadcrumb" object at first index of a List<breadcrumb> collection
This part works fine through the use of a Repeater with a LinkButton contained in an ItemTemplate. The user sees each of the pages he has been visiting in descending order, the provided benefit is a quick way to re-open records they have recently modified or created.
The part I'm having trouble handling is what happens when the user clicks the LinkButton, which is that the child page adds a new reference to the URL at the beginning of the List<> collection and I cannot seem to control the behavior of removing the LinkButton before it gets re-created. What I've tried doing is:
List<>.RemoveAt(RepeaterCommandEventArgs.Item.ItemIndex);
Repeater1.Controls.Clear();
Repeater1.DataSource = List<>;
Repeater1.DataBind();
While that should work, my CreateBreadCrumb(string url, string title) function gets called by the child page before the UserControl detects the Repeater1_ItemCommand event, so in effect it appears that the wrong ItemIndex is being used for removal.
View 1 Replies
Mar 16, 2010
I am currently binding a Nullable bit column to a listview control. When you declare a list view item I need to handle the case when the null value is used instead of just true or false.
<asp:Checkbox ID="Chk1" runat="server"
Checked='<%# HandleNullableBool(Eval("IsUsed")) %>' />
Then in the page I add a HandleNullableBool() function inside the ASPX page.
protected static bool HandleNullableBool(object value)
{
return (value == null) ? false : (bool)value;
}
This works fine but I need to use this in several pages so I tried creating a utility class with a static HandleNullableBool. But using it in the asp page does not work. Is there a way to do this in another class instead of the ASPX page?
<asp:Checkbox ID="Chk1" runat="server"
Checked='<%# Util.HandleNullableBool(Eval("IsUsed")) %>' />
View 1 Replies
Sep 8, 2010
I have created a asp.net generic handler to use it in auto-complete text box. Here is my code to it
/// <summary>
View 1 Replies
Jun 10, 2010
I have a generic handler in which I fill up a Session variable. I implemented the IRequiresSessionState interface, so it shouldn't be a problem.
In a given page, I want to display that value, but it seems like the value is always empty. Is it because the session that is accessed and written to in the handler isn't the same one that is used on this page?
In the handler, I used context.Session["EID"] = "somevalue";
edit: i found out what the issue is but I do not know how to solve it. It's because I have this Java applet which reads out an eID, calls the handler to store the data, but the session used by the applet is not the same as the session used by the browser... so how could I exchange this data in a safe way?
View 1 Replies
May 7, 2015
Below is the code for "Upload" button when uploading any file:
if (contenttype != String.Empty) {
if (File.Exists(Server.MapPath("~/Folder/'" + Txt.Text + "'/") + filename)) {
LMsg.Visible = true;
LMsg.ForeColor = Color.Red;
LMsg.Text = "File name '" + filename + "' already exist. Please change the File name to save this file";
[Code] ....
File upload control allows maximum file size is 4MB. If file size increase to 4MB it shows error page like "the page can not displayed".
I want to increase the size of uploaded files to max 10 MB not more than that. If file size increase to 10MB, it should show message.
View 1 Replies
Feb 17, 2011
What is the easiest way to save form data and retrieve it when the user navigates back to the page?
We have an application process that consists of several web forms. If the user clicks to go back a step we would like to auto-populate the fields. I am assuming there is a common generic way to do this without having to mess with individual controls - what is it?
View 4 Replies
Jan 28, 2011
Lets say I have a Web Application with a menu of products. When a user clicks a menu item, then create and display a dynamic set of controls in an Update Panel. I am currently doing this however the PostBack and recreation of controls is tedious and resource intensive.
Not sure about this but is it possible to build a webpage with controls on it, then display it in update panel or IFrame? Then on post back you wouldn't have to recreate everything all over again?
View 5 Replies
Jun 17, 2010
I am wondering if there is anyway to grab the html that is generated from an ASP page.I am trying to pull a table from the page,and I foolishly used a static html page so I would not have to be constantly querying the server where this page resides while I tested out my code.The javascript code I wrote to grab to unlabeled table from the page works.Then when I put it into practice with the real page and found that the ASP page does not generate a viewable page with a jquery .get request on the URL.
Is there any way to query the page for the table I need so that the ASP page returns a valid page on request?(I am also limited to using javascript and perl for this,the server where this will reside will not run php and I have no desire to learn ASP.NET to solve this by adding to the issue of proprietary software)
View 2 Replies
Aug 18, 2010
I am using a generic error page using ASP.NET's <customErrors> directive.
<customErrors mode="On" defaultRedirect="500.html" redirectMode="ResponseRewrite">
</customErrors>
Problem - when an error occurs, this page does not return HTTP status "500". It comes as 200. So link checkers and spiders do not see that there is any problem.
How can I send the 500 HTTP status along with the static 500.html page?
Requirements:
I must use redirectMode="ResponseRewrite" I can't use a dynamic page, only static .html.
View 6 Replies
Jun 28, 2010
I am using a generic handler (indicator.ashx) to create a graphic that is overlayed from information from a table (called LIVE) from our SQL database. This is working very well and I am very happy with the results.
However I am having an undesirable issue where the query string that is used for this is also being accessed by another page (called ReceiveLive.aspx) which is populating our LIVE table with data when we don't want this. I have been able to track this issue down to our generic handler that seems to populate this table with data whenever the handler is accessed.
The query string that is used to access our graphic through our generic handler is
http://mydomain.com/indicator.ashx?ID=ABC001.
Our other page that writes data to our LIVE database used the query string
http://mydomain.com/live.aspx?ID=ABC001 which is normally only accessed by a small piece of software that sits on the users PC and sends the data when necessary.
My question is this: How do I prevent data from being written to our LIVE table via the Live.aspx page everytime a query string is processed by my indicator.ashx is accessed?
View 10 Replies
Feb 17, 2011
I have a button in teh content page and teh master page has soem jquery scripts ,the button in the content page does not post back .
View 4 Replies
Nov 26, 2010
How can I build a query in a new page using the value from a prevous pages control's value. I can transfer the value to the new page, I just don't know how to use the passed value to build a query. I want to populate a data grid filtering with values obtained from the proveous page.
View 3 Replies