DB/Reporting :: Being Able To Change Table Name In Select Query?

Dec 6, 2008

I have a stored procedure that I need to be able to change the table name that the select statement in the stored procedure uses depending on a user input, however I am having a problem with the code:

Code:
CREATE PROCEDURE [dbo].[spQryParentComments] @projTable as varchar(50)
AS

[code].....

View 3 Replies


ADVERTISEMENT

DB/Reporting :: Getting A Value - Insert Query To Create A New Record In The Table

Nov 22, 2010

I am working with SQL Server express 2008 And visual Basic 2008. Here's what I'm trying to do, if it is possible.

I am using an Insert query to create a new record in the table. A sequential ID number is inserted into the database when the query is run in Visual Basic.

I want to capture this ID number in a variable and use it immediately following the execution of the query.

Is this possible or do I have to capture the value in a second query.

View 1 Replies

How To Select Query Multiple Table

Mar 14, 2012

how to select multiple table in vb2010? i trying to create a login so i need to retrieve the data in 3 different tables in one database i have a code but not work.[code]

View 2 Replies

Sql Query To Select Only Month Name From Table

Sep 15, 2009

My following code is only retrives number month(1,2,3,4....12)and not month name(January,February,.....December).Before that i had try using function datepart, Monthname and date_format but i still din get my answer.[code...]

View 3 Replies

VS 2005 DataSet.Table.Select Query?

Dec 16, 2010

I have created a DataSet.Within the dataset I have 2 DataTables.I have created a DataSet.Relations between the two tables.Now, using DataSet.DataTables.Select.... Would it be possible to perform a search similar to this in SQL?

SELECT * FROM DataTable1
INNER JOIN DataTable2
ON DataTable1.KeyColumn= DataTable2.KeyColumn

[code].....

View 2 Replies

Asp.net - Select Query In LINQ Based On Foreign Table

Mar 2, 2011

I have 2 Tables , OrderDetails and Requests In my LINQ to SQL dbml file. OrderDetailsID is a foreign key in Requests Table.

I want to write the query to get the sum of UnitCost from OrderDetails based on OrderId. And If there is a row in Requests Table for each OrderDetailsID, and the Requests.Last.RequestType="Refund" I want to reduce the total refund amount from the main sum otherwise If there is no row based on OrderDetailsID, add to sum.

Here is the way I implement that. I am looking to prevent using "For each".

iRefund = (From od1 In dc.OrderDetails _
Where od1.OrderID =1 _
Select od1.UnitCost).Sum

[Code]....

View 1 Replies

Select Query In LINQ Based On Foreign Table?

Mar 4, 2009

I have 2 Tables , OrderDetails and Requests In my LINQ to SQL dbml file.OrderDetailsID is a foreign key in Requests Table.I want to write the query to get the sum of UnitCost from OrderDetails based on OrderId.And If there is a row in Requests Table for each rderDetailsID, and the Requests.Last.RequestType="Refund" I want to reduce the total refund amount from the main sum otherwise If there is no row based on OrderDetailsID, add to sum

View 3 Replies

SQL Select From A Table In An Oracle Database, And Show Results Of Query In VB Application

May 14, 2009

I want to (SQL) select from a table in an Oracle database, and show the results of the query in the VB application, in a Excel like manner (rows, columns, selectable, etc.). Or in a SQL developer manner. How can I do that? Browsed through a lot of tutorials and howtos on the internet, did not get anywhere. I think (and correct me if I am wrong) that it's gotta be something with DataGridView. But I don't know how to create and populate a datatable with the result of as Select statement, how to create a dataset.

View 3 Replies

DB/Reporting :: SQL Select Query In Form - Form With A Datagridview That Displays All Of The Values

Mar 26, 2008

I am using VB2008 Express and a MSSQL Server 2005 db by the way! I have a comprehensive SQL statement, which should fill my Grid:

DECLARE @Sum NUMERIC(9,2)
SELECT @Sum = SUM(I_LS.lmenge)
FROM dbo.lfs AS I_L

[CODE]...

Now here is my problem! I want to have a form with a datagridview that displays all of the values I am querying. This shouldn't be a problem I guess. However, I have no idea how I can integrate two textboxes that can be used to enter the selection criteria (WHERE I_L.lfsnr LIKE '%1253') AND (l.sped_journal = '11-08')[/SIZE]. I have googled and read many threads so far but didn't stumble upon anything that would suit my needs and answer my question. Maybe it's just too elementary!? By the way, it is very important that the input of textbox1 ((WHERE I_L.lfsnr LIKE '%1253')) is linked to 3 positions in my SQL query to define the search criteria!

The worst thing is that I don't want to have a bindingnav displayed! I do not need any delete, update or add functions just the select option, however!

View 1 Replies

DB/Reporting :: Attach A Dataset To A Table (MS Reporting)?

Jan 9, 2009

I want to do something like this:

Code:
'create a dataset and a table
Dim ds As New DataSet

[code].....

View 5 Replies

Select To Multiple Sql Tables Using Select Query?

Jul 23, 2011

I want to select to multiple sql tables using select query in vb.net..I have 2columns in sql table..I have tried this query.. But i'm getting error.

TextBox11.Text = Val(27)
cmd = New SqlCommand("SELECT outside,power FROM vijay21 INNER JOIN vijay22 ON vijay21.outside=vijay22.outside WHERE outside BETWEEN " & Val(TextBox11.Text) & " AND " &

[code].....

View 4 Replies

Correct SQL Query: Error "Microsoft Jet Database Engine Cannot Find The Input Table Or Query 'IF'?

Aug 27, 2010

The database:
"ID (Primary key)" | "Title"
0 | "title1"

[code].....

OK, before adding values to database, we should check if a row exists with this values :)TO do this, creating a Stored Procedure is a best way to deal with the database fastly.So... The problem now is, at the runtime, Miss OleDB throw this error:Microsoft Jet database engine cannot find the input table or query 'IF

View 2 Replies

Correct This SQL Query: Error "Microsoft Jet Database Engine Cannot Find The Input Table Or Query 'IF'?

May 29, 2009

i should say hi experts :D . Help me with this pretty code :)

The database:
"ID (Primary key)" | "Title"
0 | "title1"

[code].....

OK, before adding values to database, we should check if a row exists with this values :)TO do this, creating a Stored Procedure is a best way to deal with the database fastly.So... The problem now is, at the runtime, Miss OleDB throw this error:Microsoft Jet database engine cannot find the input table or query 'IF

View 11 Replies

Javascript - Make A Select Option Change Options In Another Select?

Oct 3, 2011

I have two drop down. SelCurrentManuf and selCurrentModel. I want the option in selCurrentModel to change depending on the option selected in selCurrentManuf. How do i do it?

<asp:DropDownList runat="server" ID="selCurrentManuf"></asp:DropDownList>
<asp:DropDownList runat="server" ID="selCurrentModel"></asp:DropDownList>

This is how i am currently populating selCurrentModel

Public Sub PopulateCurrentModel()
Dim mySelectQuery As String = "SELECT * FROM Model where ManufID = "+ selCurrentManuf.Text+";"
Dim myConnection As New MySqlConnection(Session("localConn"))

[Code]...

but it only populates the first selected manuf, and doesnt change after

Private Sub selCurrentManuf_SelectedIndexChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles selCurrentManuf.SelectedIndexChanged
PopulateCurrentModel()
End Sub

View 2 Replies

Query A DataTable - Change The Query At Runtime (ex. Changing The Customer Name)

Oct 15, 2011

I created a RDCL in the designer. I would like the User to Determine what is shown in the Report. How can I change the query at runtime? (ex. changing the customer Name)

This is the query that I have in the properties:

SELECT [Date], Address, Customer, Orders
FROM Report_qry
WHERE (Customer= 'JohnDoe')

View 5 Replies

DB/Reporting :: Table Columns Into Table Adaptor?

Jul 7, 2011

Rather than running numerous queries in Access I am trying to write a front end for a DB2 database. The Access database is getting to a size that it is causing Access 2007 to have reliability issues and frequent compacting is required. I have created the Dataset, the Table Adaptors, and the Connection String already, but when I put in a bit of code in to fill the Table Adaptors the remote connection I have to work is going crazy (chewed up about 180MB before I realised it was pulling data from work).

Before I started the project I copied the .accdb to my local PC HDD and I pointed the connection string to it, but it still looks like it is trying to pull data from the work network. If it was a small database I wouldnt be concerned but it is pulling major data every time I run it. I have only 2 out of the 4 Table Adaptors running and it didnt fill them even after 10 minutes.

Here is the code I was trying to run... Server name has been substituted for Server for obvious work reasons.

Because the tables are so large I was looking for a way to pull only the columns I need to from the tables, I tried adding .SOFT_ID to the first line of code but the TA spat the dummy message below...

Value of type 'System.Data.DataColumn' cannot be converted to Application_Name.DS_DB2Database.Server_SOFTDataTable'.

Code:
Me.TA_ServerSOFT.Fill(Me.DS_DB2Database.ServerSOFT.SOFT_ID)
Me.TA_ServerSOFT_FOUND.Fill(Me.DS_DB2Database.ServerSOFT_FOUND)
Me.TA_ServerHARD.Fill(Me.DS_DB2Database.ServerHARD)
Me.TA_ServerREF_SUP.Fill(Me.DS_DB2Database.ServerREF_SUP)

I would also like to pull just the data columns I need to speed up the query.

Note: In case youre wondering why I am not connecting directly to the DB2 database. I currently dont know where it is stored and while leveraging Access I am trying to put a level of separation between the app and the db for the time being, later I will try connect directly.

View 9 Replies

SQL Server Query Combination - Get Rows From A Table Based On The Value Of A Field In Another Table

Feb 23, 2011

I have a query that I have to run that requires me to get rows from a table based on the value of a field in another table (which I have gotten earlier). I currently have it done like this (simplified).

[Code]...

View 1 Replies

C# - LINQ To SQL Join Two Tables To Select Parent Table Twice Based On Two Different Columns From Child Table?

Aug 23, 2010

I have two tables Employees and CafeLogs. Some employees can be cashiers and also customers at the Cafe shop.

Table structures:

Employees: EmployeeId(PK) , FirstName, LastName
CafeLogs: LogId (PK), CashierId, EmployeeId, Value, => CashierId and EmployeeId are the data from column EmployeeId of Empoyee table

Table relationship:

Employees 1:N CafeLogs (CashierId (FK))

[code]....

Right now I know how to select only LogId, Employee's name, and , Value, not with Cashier name yet.

Dim query = From log In db.CafeLogs _
Join emp In db.Employees On emp.EmployeeId Equals log.EmployeeId _
Select log.LogId, emp.FirsName, emp.LastName, log.Value

View 1 Replies

MySQL SQL Command To Query From One Table With Three Same Columns To Another Table?

Jun 13, 2012

My problem is with the tickets table, I have listed the user that created the ticket, the tech who will solve the ticket and a user that over sees the ticket. All three users reference the users table. So how do I can I query the tickets table and get all three users that reference the same table storing the users?

Table1: Tickets
1) Ticketnumber
2) EnteredBy User 100
3) Issue

[code]....

What I can do now is something like this:

Select Ticketnumber, EnteredBy, Issue, UserName FROM Tickets INNER JOIN Users
ON Tickets.EnteredBy = Users.UserID

View 3 Replies

DB/Reporting :: Reporting During Query?

Feb 25, 2011

I have a form that when you click a button it begins a query. I want the user to know that they already started a query and they basically need to wait and not hit the button again. To do this I have a list box that has an lbResults.item.add() to it

Code:
Private Sub btnControlKSMS1117Query_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnControlKSMS1117Query.Click

[code]....

View 1 Replies

How To Get Name Of Table-to-be-made By A Table Make Query

Sep 17, 2010

I am trying to automate an access table make query through vb.net.It works fine the first time, but the second time it fails because the table already exists.Of course i can delete the table through code by it's name, but i want to let my .net-application find out wich table must be deleted. Or maybe there is a solution that doesn't fail with the error "table exists" without first deleting it.[code]

View 1 Replies

DB/Reporting :: Select Second Highest Value?

Nov 25, 2008

I'm having a problem with my Access database.I have to select the highest ActieAantal before the last action ( )because the last action is always the sum (Totaal).this is a part from my table

Persoonid..........ActieAantal..........acties..........Actieid....... ...datum..........aantal..........totaal
.......... 3 ................ 1 ................... aa ................. 99 ........ 31/12/1975
.......... 3 ................ 2 ................... bb 94 ............. 98 ....... 31/12/1975 ........ 94
.......... 3 ................ 3 ................... cc 10 ............... 5 ....... 17/03/1989 ....... 10
.......... 3 ................ 4 ................... dd 20 ............... 2 ....... 25/08/2003 ....... 20
.......... 3 ............. 999 ............. totaal = 124............. 9 . . . . . . . . . . . . . . . . . . . . . . . . . 124

The next person also has some acties with corresponding Actieid and a Total when I use this query I alway get the 999 values

SELECT Register.Persoonid, Max(Register.ActieAantal) AS MaxVanActieAantal
FROM Register
GROUP BY Register.Persoonid
ORDER BY Register.Persoonid, Max(Register.ActieAantal);

but when I try to exclude the 999 value I get nothing

SELECT Register.Persoonid, Max(Register.ActieAantal) AS MaxVanActieAantal
FROM Register
GROUP BY Register.Persoonid
HAVING (((Max(Register.ActieAantal))<>999))
ORDER BY Register.Persoonid, Max(Register.ActieAantal);

find the highest 'ActieAantal' after excluding the 999 values?

View 2 Replies

DB/Reporting :: Use The Select Statements In VB?

Jun 28, 2011

Not sure if this is possible but can you use the select statements in VB to pull in from not just one but multiple tables and put the data in a gridview? [URL]

Code:
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1

[Code].....

View 3 Replies

DB/Reporting :: Using Tow Select In Same Statement?

Dec 29, 2008

I'm using Vb2005 and Db MS access Is it possible to use tow Select in same sql Statement like this example:

Code:
"Select....Select......."

View 5 Replies

DB/Reporting :: Get Query Of Views In .net?

May 22, 2008

anyone knows how to fetch the query of a view (Sql server) in vb.net?

View 3 Replies

DB/Reporting :: Select Data With A DropDown?

May 11, 2008

I want to take a drop down menu. It will contain LastName, FirstName. I want that to select a record from a table. First Name and LastName are two different columns

View 5 Replies

DB/Reporting :: Select Stored To An Array?

Jun 3, 2009

Im new to database programming and was wondering if you can save a select statement to an array:I tried this but obviously wont work, does anyone have any ideas?

Code:
Public Sub store_select_star_to_array()
Dim myCommand

[code]......

View 2 Replies

DB/Reporting :: Select The Data From The Database?

Feb 25, 2008

Ive got a web page so that the users select a day from the calendar and the date is input to a text box, the format is dd/mm/yyyy, it is the same format in the database table.

I want to select the data from the database when it is = the date in the text box but it is retrieving data in mm/dd/yyyy format. My sql is:

SELECT Booking.Date, Booking.RoomNo, Booking.Lesson, [NoComps] - " & students & " AS diff FROM Rooms INNER JOIN Booking ON Rooms.RoomNo = Booking.RoomNo WHERE booking.Date= #" & txtdate.Text & "# AND booking.Lesson = '" & lessonlist.SelectedValue & "' AND booking.Type IS NULL

how can i make sure it retrieves the data using the correct date format?

View 1 Replies

DB/Reporting :: Selecting Within A Select Command?

Nov 1, 2010

I need to filter a measurements table that consists of 63 measurement objects that may or may not be tested more then once. The entries are put in a Batch table on a SQL server in the following fashion:

ID: | Serie | Test object | Min Amps | Max Amps | OK?
DateTime| String | Integer | Double | Double | Boolean

So there may be multiple entries in my database with the same series and testobject number but with (slightly) different results.

Currently I just select: SELECT * FROM Measurements WHERE Serie = 'XXXX' and use a datareader object to fill a datatable and then I let loose a routine on it that will either: Get the last result that produced a good measurement, so OK = 1 and max ID. Or the last result that produced a bad measurement if there are no good ones. I then end up with a list of 63 either good or bad measurement objects with the last good result, and if there isn't one then the last bad result.

Now I know that SQL is quite powerfull and I suppose that it must be possible to directly query for these results without a programatical routine re-filtering the results. I suppose it's like Selecting within a select statement..

View 2 Replies

DB/Reporting :: SQL Select Row And Update Recordset?

May 1, 2008

I am trying to use sql to select a row and then find the minimum and maximum values in the row, do some preprocessing, update the recordset using in visual basic 6.0, and then go ahead select the second row, find the minimum and maximum values again.. and go on, until the last row.

The problem is I am having difficulties using sql select for a ROWS.. I am aware how to do this for COLUMNS.. if I want to extract the first row from a recordset, find the min max values, and then, extract the second row and so on.. how will it be possible? (discouraged to use VBA, since i am limited to VB only)..

Here is an example of my recordset:

Code:
Col1Col2Col3Col4Col5
0.43530.05630.74350.92510.0325
0.28430.00320.82430.73250.9981

This example only lists two rows currently. I want to extract the minimum and maximum values from each row at a time, and then the second row. The reason for extracting minimum and maximum values is because I want to normalize my data in the range from 0 to 1.

Logic: After I find the min and maximum values for each row, I will use the recordset back, read the same row, and update every columns entry with my normalized data value... then proceed to the next row and do the same for every row in my database.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved