Access :: Two Databases In One Select Statement?
Jun 10, 2010"SELECT a.fibunr, " & _
View 14 Replies"SELECT a.fibunr, " & _
View 14 RepliesI have a select statement where I want to get some data. The problem is that I am not geting the right answer. This is what I am trying to do:
SELECT * FROM se_cs_test WHERE
Status = 1
OR Status = 2
AND NumberOfContacts = 1[code]...
I'm trying to read Excel file header column name. Then I can query data from excel using SELECT statement. For instance. column name is name,
department and email. Then I want this three header name being detected using code and put in select statement. User no need to care about the
header name and we can use code to read the header name instead of hardcode header name inside SELECT statement.
I am wondering there is no one asking this question on the internet even I have used google. (May be I am using a strange way on this case)
Here is the insert statement with select statement
Insert into a_table (ref, user, pw) values ((Select max(ref)+1 from reference_table), txtUser.text, txtPw.text);
Ignore the sql injection first, this statement is incorrect. Any idea? thx.
My students are working on an ASP.net VB application for a Web Programming competition and we are having problems with a page where we want an URL string to return all values from our database. Here is the page: [URL] If you use the jobs by category menu on the left side, if you select a job category (ie retail) it will pull up all the jobs from that category. By using a query in the URL like this: [URL] What we need is an option that would pull up all of the records regardless of category. So we made a menu option that passes the value "all". Like this: [URL] We use this information for the dataset we created (we're using Dreamweaver, ASP.net VB and and Access Dbase). We made a dataset SQL as follows:
SELECT *
FROM jobs, businesses
WHERE jobs.contactlogin=businesses.contactlogin and jobcategory = ?
ORDER BY jobs.dateposted DESC
This works fine if a value is passed. For example if "retail" is picked from the menu it passes the value just fine and returns all jobs that have "retail" as the job category in the database. My problem is, how do I modify the above Select statement to show all jobs in the database if the value "all" is passed for the jobcategory. My first thought was to create an If statement that says something to the effect of:
If jobcategory = all THEN
SELECT *
FROM jobs, businesses
WHERE jobs.contactlogin=businesses.contactlogin
ORDER BY jobs.dateposted DESC
ELSE
SELECT *
FROM jobs, businesses
WHERE jobs.contactlogin=businesses.contactlogin and jobcategory = ?
ORDER BY jobs.dateposted DESC
END IF
But I haven't been able to figure out the correct syntax. I also tried making this work by using a query in MS Access:
SELECT *
FROM jobs, businesses
WHERE jobs.contactlogin=businesses.contactlogin
AND (jobcategory = @jobcategory or @jobcategory = 'all')
ORDER BY jobs.dateposted DESC;
(which does work within MS Access) and calling the query in the Dreamweaver dataset but apparently MS Access can't do that.This seems like it should be easy but so far this problem is kicking my butt.
i'm trying to to create a simple string array with data retrieved from a select statement(SELECT firstname FROM customers , for ex.)
View 6 RepliesHow would i make a select statement select the row with the nearest values? e.g.: I have 3 labels, labels1 2 and 3, with values of 1.2, 2 and 5.8 In my table i have 4 columns, first is the data im after, and the next 3 relate to the three labels. I want to select one row, where the values of labels match it the closest.......
View 8 Repliesi have two tables named
1.LookupPageInfo and (LookupPageInfoId,pathmessageID,pagemessageID)
2.Messages (MessageId,MessageText,ChannelID)
Now i need to write a query something like this........in the query i need to pass the pathmessageid and needs to get messagetext from Messages Table,i am not sure how i need to write the below query..can someone guide me how can i write a query......as below..
select LookupPageInfoId,
PathMessageID,
pagemessageID,
(select messagetext from Messages where MessageID=PathmessageId) as TEXT from LookupPageInfo
i want to develop a data access layer ,it can support multiple database like oracle ,Mssqlserver and Mysql using enterprise library and C#.net 3.5 based on database connection
View 1 Repliesat present our site has a search function which then populates a grid with results from our catalogue database... I'm trying to implement product availability into the grid, but the stock information is stored in a completely different database in a different location. Both the main search results and the stock levels have to be referenced in the same datasource to get them both in the same grid; does anyone have any thoughts on how to do this? I'm not hugely experienced with SQL, but could I create a view containing aspects of both db's or are these limited to a single db?
View 3 RepliesI'm having problem getting the syntax right for an SQL statement for a Progress database. I have the column "Resource" which is a reserved word and according to the Openedge SQL Reference I can only use reserved words if I delimit them with double quotation marks.
So how do I write this line...
Dim comm As New OdbcCommand("SELECT Resource FROM PUB.ActOper WHERE CreDate > TO_DATE ('05/24/2010')", conn)
...with double quotes around Resource? I've tried a bunch of different combinations but I get "Expression expected" or "valid continuation expected" or something similar.
actuly my site is working fine but suddenly site is giving "ORA-24338: statement handle not executed" this error i'm try to resolve this error but i could not get proper solution
my prblm is tht when i access my site on my PC using "www.xyz.in" at tht time i access my site with report properly but whn i access my site on out of company or any cyber cafe or other internet pc thn i could nt access my site properly tht site is give me error.......
ORA-24338: statement handle not executed
i'm use oracle10g & database connection in "system.data.oracleclient" & most imp thing i;m using site number of years
how to get the sql statement query or table name if oledbexception occurs - table or view does not exists.
get the DB details from the oledb exception.
I have two dropdown list, which is 'names' and 'types' and it's being populated by a dataset. It contains an additional item "-- ALL --" to indicate that all items of a particular field are being shown. I have an SQL select statement to filter the records according to the selected item of the dropdowns. I used a select statement to bind the records to a datagrid with regards to the selected items.
SELECT * FROM table where name = ddlnameselecteditem AND type = ddltypeselecteditem
The problem now is when I select a name from the names dropdownlist and types dropdownlist has a selection of -- ALL --, there would be no return records because there's no such thing as '-- ALL --' record in column 'types' i'm querying. I need to display rows of the selected 'name' while still showing all the 'types'. How could I achieve this? I think I need to avoid the '-- ALL --' item from the dropdownlist.
I'm pretty new at ASP. I've got a sheet I'm trying to modify using an IF statement. I tried putting them in, in different ways, but it either shows up in the form or I get the options multiple times
[Code]....
i have a variable picked up elsewhere strArea, so I was trying to do
something like
[Code]....
I have tried putting the if's in different places, as well as case statement
but usually I end up with my drop down option list as
1
1
2
1
2
3
I'm trying to pull a list of clients that have both of two codes in the code table. Here is what I have tried and it does not return any rows. I know that there are clients that have both codes.
[Code]....
I am working on LINQ I m feeling difficult with getting the value from the LIST. Here is the following code
ccDataContext context = new ccDataContext();
I have the following select statement :
string Statement = "SELECT * FROM Car WHERE brand = Bmw;
how is it possble to display the result from the statement, because when i display the result exp: LblInfo.Text = Statement;
The result is : SELECT * FROM Car WHERE Brand = Bmw
I have records in the datatable which I have retreived from xml file.
Dim docDataSet As New DataSet
Dim docReader As New XmlDocument
Dim xnl As XmlNodeList
docReader.Load("UserProfile.xml")
xnl = docReader.SelectNodes("/Users/user")
For Each xn As XmlNode In xnl
Dim xr As New XmlNodeReader(xn)
docDataSet.ReadXml(xr)
Next xn
Dim Dm_table As DataTable = ds.tables(0)
Now what I want to do is execute a select query like below:
Select * from user where userid in (select ID from Dm_table)
Retreive the records from the User table based on the ID's in the datatable.
I thought this would be easy but cannot now find out of to do it. All I want to do is execute an sql query on a table and in addition to the table's columns I want to also select/output a field that is calculated within the query. The table has a column "Owner" and I want to compare this to the UserId to produce a bool column "mine". Effectively doing:Select *, (Owner=@UserId) as mine where.....however, this doesn't work so how can I calculate a column in the select statement?
View 3 RepliesI have to pull up a list of people by their branch number which could vary, and give a detailed report on there performance using a select queries. I have the select queries but how can i create a script to look similar to this one. Ive got the branch drop downlist already created just need to know how i can go about pulling all the users in this group and doing this select to all of them. someone told me I might need to use cursors to loop thru a select with every person in the list but im not sure how to go about that.
select fldusername from tbluser where fldio='o' and
flduserbranch=@branchid
is going to give me the names of the people i need to query. but how can i run a query on each of them seperate?
Here is the deal. I need to create a Stored Procedure that has 2 SELECT statements. Now in ASP.NET, I know that a DataSet can have multiple tables and the DataAdapter can do just that. I am stuck with a scenario where I need to get a value from the first SELECT statement which will later be used in the second SELECT statement. I am creating a SP that passes one parameter (@AnswerID). Which should give me 2 resultsets. See below SELECT statements.
[Code]....
So how do I get the QuestionID from the first SELECT statement?
Basically I am creating a Questionnaire that has Question Dependacies. So from the above SQL statements I would like to display the Question Title with it's relevant answer options but depending on the previous Answer selected hence the @AnswerID parameter.
The reason why I want to use 2 SELECT statements is because I don't want to have 2 roundtrips to th server. So in my code the DataAdapter should return 2 resultsets and fill the DataSet.
If there is any another solution that can prevent 2 roundtrips to the server, I would most definitely like to know how to do it.
Here's my SQL Statement
[Code]....
Unfortunately, I get the following error message:Message="The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified."
I have a select statement:
cmd = new SqlCommand("select lab_key from tblorderwhere", connection);
I would like to add a where statement that pass variable to the select statement. How I can do this?
Where lab_key =ChargeFine( that is my variable)
I am using join to get values from three tables. I want the first column to be Sl.No which autoincrements by 1.What should i write in the select for the first column.
View 4 Replies