Is it possible to add multiple select statements in a single stored procedure. The select statements are getting data from different tables. If yes, could anybody provide an example in adding multiple select statements, which retrieve data from different tables in a stored procedure.
I want to insert a record into a log table ONLY if one exact copy already doesn't exist within ten days, what is a good way to do in one stored procedure what I do above in two?
I tried to find a LINQ section on this forum, but couldn't, so I'll post this here since is deals with LINQ, C#, MVC, SQL Server, and well...just about everything.
Here's the details....My Application is an ASP .Net MVC 1.0 app, using C# 3.5, SQL Server 2005 Std, and LINQ to Entity.
In my View, I have numerous Html.CheckBox controls, they get passed to my Controller as a string collection via a JQuery Ajax call. The values of each checkbox are seperated by a comma(,). I then Split the string, to get the individual values. The overall purpose to to allow users to build a custom report with only the data elements they have checked the boxes for. Here is my controller:
[Code]....
The part that I am having a problem with is that I only want to Insert the data elements into my DB table for the ones that the user has selected the checkbox for. So, for example, I'd like to do something like this:
[Code]....
I don't know if there is a LINQ switch statement in which I can access outside variables and the columns of the table, or any thing like that.
I'm using the 'Configure Data Source' wizard to connect to my database and show the dataset in Gridview. I want to be able to update, insert and delete entries but am unsure how to build the query. I can write simple update statments to change database entries but how can I do this for entries that have been changed within the gridview?
When can I use Stored Procedure? Is this useful for looping into multiple SELECT statements to return single value? How? Can anyone post some sample codes? I have text query and notice that my web application is slow and want to find ways to speed it up. Is there any possible ways aside from Stored Procedures?
i create view in sql server and execute a select query using AND operator on it using vb.net and bind data with gridview...but i am not getting result in grid
in DataBase Attendancedate is save in this format 4/5/2010 4:16:28 PM ..i want to query like this select * from EmployeeAttendance where Attendancedate='4/5/2010' but this giv error
I am having difficulty selecting data from 2 tables that do no share a primary key value. For instance, I have an actual table, a forecast table, and a GLText table. I may have an actual value but not a forecast value but I need them to appear in the same Query (like the query results shown below). I can get all values to appear in each table but have been unsuccessful in getting all values from both tables.
I have an application that I am developing using ASP.Net with visual basic code. I have a table called "Customers" that contains 3 fields. The name of each field is "Name", "LocationA", and "LocationB". I want to code a select query that list two columns. The first column should contain the field "Name". I want the second column to contain the value in the field "LocationB" if "LocationB" is not null, else I want the second column to contain the value in the field "LocationA".
I have dropdownlist of dates and depending on the date that the user selects from list, I would like to filter records that fall between the startyear and finishyear columns in the datasource. (My the problem is that I do not know how to declare the Startyear and Endyear from the query in the code as they appear underlined - probably the BETWEEN syntax is wrong too).
yYear = DropDownList1.Text Using connection As New SqlConnection("Data Source=CHRIS-PCSQLEXPRESS;Initial Catalog=TorGHL;Integrated Security=True") Dim cmd As String cmd = "SELECT BarDetails.*, MenuHeadingId AS Expr1 FROM BarDetails WHERE (MenuHeadingId = 2)" & "WHERE " & yYear & " BETWEEN " & "(" & StartYear & ")" & " AND " & "(" & EndYear & ")" connection.Open() Dim dapubcb As New SqlDataAdapterDim sqlcomm As New SqlCommand(cmd, connection) dapubcb.SelectCommand = sqlcomm Dim dspubcb As New DataSet("BarDetails") dapubcb.Fill(dspubcb, "BarDetails")
I have a table called 'Customer' that contains customer information. One of the fields is named "CustomerType". Each record in the 'Customer' table will contain the value of either "C", "I", or "O".
I have a form that contains a "check box list" named "Type". There are 3 values in the "check box list". The values are "C", "I", and "O". The user can select one or more of these values. I have a button on the form named "btnRunQuery.
When the user clicks on the button "btnRunQuery" I want to exectute a query that selects the records contained in the "Customer" table where the value in the field "CustomerType" equal the values the user selected in the "check box list". Example: If the user selected "C" and "O", then I want the select query to select all records that contain either "C" or "O" in the field "CustomerType".
I assume that what I need to do is to capture the values that the user selected in the "check box list" and put them in a variable. Then I need to format the "Where" statement in the query and add a "Parameters.AddWithValue" command.
I have a basic CMS which I'm adding to a site to display some downloads organised into groups. I have two tables, one for the groups and one for the downloads. I'm using a repeated to display the groups with another repeater inside to display the children. This works perfectly.
However some of my download groups may not have any downloads related to them and I'd like to handle this by filter the groups so that only those with a relate download record(s) are shown.
I'm trying to do this with the query which populates the top repeater based on some ideas I read but I must be going wrong with the syntax.
Here is what I'm using to try and only select downloads groups which have downloads linked to them by the download group ID.
[Code]....
Can anyone offer any thoughts on how I should construct the query to perform this?
A bit new to buttonfields in gridviews - Did a bit of research and most of the stuff I came up with had the gridviews with data bound like so :
[Code]....
private void BindGridControl() {//method created so that the binded gridview can allow paging controls DataTable dt = new DataTable(); try { /*Gridview requires another column either a checkbox or a hyperlink column that * can drill down another level and load a page where user can edit the data/cheque * Will place an exception here that will prompt a window to notify users that there were no rows returned */ GridView1.Visible = true; sqlConn.Open(); sqlSearch = "select store_nbr as [Store number],date as Date,data_type as [Data type],acct_1 as [Account 1], "; sqlSearch += "amt_1 as [Amount 1],acct_2 as [Account 2],amt_2 as [Amount 2], "; sqlSearch += "acct_3 as [Account 3], amt_3 as [Amount 3], cheque_nbr as [Cheque Number], "; sqlSearch += "cheque_amt as [Cheque Amount], gst_hst as [GST/HST], qst as [QST],comments as [Comment] "; sqlSearch += "from SimpData where store_nbr = '" + StoreNum + "'"; sqlCmd = new SqlCommand(sqlSearch, sqlConn); SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd); adapter.Fill(dt); if (dt.Rows.Count > 0) { //if there are rows returned bind the datasource to the gridview GridView1.DataSource = dt; GridView1.DataBind(); } else { //label control notifies user that there are no rows found lblResults.Text = "Search returned no rows"; } My ButtonFields<Columns> <asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select item" ShowHeader="True" Text="Select1"> <ControlStyle Width="50px" /> <HeaderStyle Font-Size="XX-Small" /> </asp:ButtonField> <asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select item" ShowHeader="True" Text="Select2"> <ControlStyle Width="50px" /> <HeaderStyle Font-Size="XX-Small" /> </asp:ButtonField> <asp:ButtonField ButtonType="Button" CommandName="Select" HeaderText="Select item " ShowHeader="True" Text="Select3"> <ControlStyle Width="50px" /> <HeaderStyle Font-Size="XX-Small" /> </asp:ButtonField> </Columns>
VS 2008 ASP.NET 3.5 app connecting to an MS SQL 2005 backend. The app contains a strongly typed dataset with a number of TableAdapters. I'm trying to add a query to one of the TableAdapters that deletes from table A, then related entries from table B, then related entries in the master table - table C. The query looks like this:
[Code]....
When I try to run that query to test it out, an error dialog box pops up that says "Unable to parse query text" followed by a second error dialog box that says "Must declare scalar variable @ID". Will the TableAdapters not run sequential Delete statements like this or did I do something wrong?
**Side note: A cascading Delete foriegn key relationship would be ideal, and was configured on the development database, but the DBAs messed up when replicating the database on the production server and getting them to fix something like this can be a difficult process.
the best way to achieve the following:A products table linked to an images table where 1 product can have many images.Simple scenario is to select a product and its images using
select * from products where id=5 select * from images where pid =5
So far so good, its easily mapped to an object once the query has executed with ado.net.
what if i want to select all products and their related images and map them to a Product object, the result is as follows
if I have three Dropdownlist A, B, C, how can I write a select statement to get data from sql server based on the dropdownlist selected.e.g. if user select dropdownlist A, select * from table where A = dropdownlist A but if user select dropdownlist A and C, then select statment is "select * from table where A = dropdownlist A and B = dropdownlist B or if selected A, B, C.......how can I settle so many choice.