I wish to build a select statement with the "WHERE" part is a variable. I know how to do
Select * FROM table WHERE colum = '" &variable& "' But what if I want the whole part after WHERE to be a variable? with acutal other variables in it.. for instance....
Dim rs, var1, var2, QryString
Set var1 = 1
Set var2 = 2
set QryString = colum1 = '" &var1& "' AND colum2 = '" &var2& "'
rs = Conn.Execute("SELECT * FROM table WHERE QryString")
I am looking for the correct syntax in this case... assume my database connections and such are correct.
I have an old web app that ues an Access database and ASP 3.0. I need to build an INSERT statement based on the contents of a form. What is the best way to handle blank text boxes that are submitted with the form?
For example, I collect all my name/value pairs that are submitted with the form like this... Code:
Now, in the above, I would like to be able to put the location field as 'Don's room'. In other words, I would like to handle the aprostrophe after Don. With this in mind I am changing the code as following: Code:
I am trying to display a feild from the table. But there is a Type Mismatch error that I am getting. Can anyone please take a look at my code to see what could be wrong.
The error that i am getting is: Microsoft VBScript runtime error '800a000d'
Type mismatch
/jobapplicationnew.asp, line 1285 Line 1285 is highlighted.
following is my select statment code, works partially fine but the city search is not working.. i.e it gives me list of all hotels that start with the given words whereas it should give me hotels in the given city only. pls help me out. thanks
the select statement as per the following relationships:
drop1id has 1 to 9 records. drop2id has 1 to 65 records - FK drop1id will be 1 to 9 drop3id has 1 to 356 records - FK drop2id will be 1 to 65 drop4id has 1 to 356 records - FK drop3id will be 1 to 356.
I am not sure how to retreive the records based on their relationships.
does anyone know if its possible to look through a field in a database and see if it contains certain keywords?
i am using a database with a field called MainIssue and i want to see if it contains keywords and if it does, to display the contents. is there a command which would do the same thing as:
select * from maintable where field contains "keywords"
I am having problems with a select statement in asp with an access database. I pull First and Last information from my form First = Comes from form Last = Comes from form I have validated that the form information is being pulled this is where my problem lies. Code: SQL = "Select Listing where (FirstName =" & First & ") AND (LastName =" & Last & ")" For some reason I can not pull the information for the database using this. If I take the AND (LastName =" & Last & ") out I can pull some of the information, but I am looking for a specific last name, first name entry.
all tables have the same columns with the same type of data.
code, description, activated etc.
now i ask the user to enter a code, and then it searches through all the tables for that code. the reason i broke it into smaller tables is there is 10s of thousands of records. it should find the record that match with the entered code and then if the user wants to, he can edit the data, the date is then automatically saved into the record as well.
Some of my pages include paging where the variable starts with a certain letter. This worked fine in access but when I try to run it with mysql it says...
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'
[MySQL][ODBC 3.51 Driver][mysqld-4.0.17-nt]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT username, status FROM users WHERE username Like 'A%' OR
This is really simple but for some reason no recordset is returning. I can't get cat_1 to write. I have run the query against the database in Query Analyser and it runs fine.
Code: Dim objConn Set objConn = Server.CreateObject("ADODB.Connection") objConn.ConnectionString = "Driver={SQL Server};Server=nzlakldwhse;Database=Complaints;Uid=elkuser;Pwd=elk;" objConn.Open
Dim objRS Dim cat_id, cat_1, cat_2 set objRS = objConn.Execute("select cat_id, cat_1 from complaints.dbo.category a where a.cat_id = '"& request.form("cat_id") &"'")
How do i get this to work, i have 3 colums forename, surname and groupname and a colum Genre. I want to select any of the 3 first colums for a name, where the Genre colum is X this is the statment i have Code:
"select * FROM autos WHERE forename LIKE '" & session("name") & "' OR surname LIKE '" & session("name") & "' OR groupname LIKE '" & session("name") & "' AND genre LIKE '" & session("genre") & "'"
this is what i get :- select * FROM autos WHERE forename LIKE 'david' OR surname LIKE 'david' OR groupname LIKE 'david' AND genre LIKE 'Football' giving David and 'session("name") and Football as session("football")
I've inherited a database with NULL values in it. I plan on fixing this problem, but for now I need to get this statement working.
cmd = "SELECT * FROM EmpInfo WHERE Interview <> NULL AND status IS NULL OR status <> 'D'"
I'm trying to pull information from the table that need to conform to two different rules. First, there needs to be a value in the INTERVIEW column.
Second, the column STATUS has to be NULL, there can be no D (for delete) in the record.
I can get it to pull the records following the conditions for STATUS, but not for INTERVIEW. I don't work with NULL values very often, so this one is throwing me for a loop.
How can I write that statement to pull only those records that are not NULL in one column, but NULL in another?
I've got a client who needs some ASP's coded for a Unix server running ChiliSoft, (I had no say in the matter).
I'm banging my head against a wall with the following code: [VBS]Set objRs = Server.CreateObject("ADODB.Recordset") Set objRs.ActiveConnection = objConn objRs.Open "Select * From tblDataBank_Summer Where DatabankID = " & intDatabankID, , adOpenStatic, adLockOptimistic, adCmdTable[/VBS]
I've used this coding elsewhere on other sites with no troubles, but here I keep getting:
ADODB.Recordset.1 error '80004005'
SQLState: 42000 Native Error Code: 1064 [TCX][MyODBC]You have an error in your SQL syntax near 'Select * From tblDataBank_Suummer Where DatabankID = 114 ' at line 1
im in need of some guidence regarding select statements. is it possible to combine to select statements?reason for asking is i got this in my access mdb i have to queries one to get the specific member for witch i want the sum from and name is used as creteria then the secon queri is the sum it selfe by using grouped and name as creteria that works well but if i want this on a asp page it becomes little dificult.
well i cant see how can be done as i hoping some of u out there do i was thinking of combining the 2 so the first select gets the info then sum as secon select in a combined select statement i dunno if thats possible. or is there a way i could just use a select all from table and a asp function that can sumerize a field and then put that as a response.write?
i need select statements that counts records from my access database where the time difference is worked out between two fields (datein;dateclosed). Less than 24 hours, >3 days, >5 days, >10 days, >15 days, >30 days, >60 days, >90 days
i am not sure how to construct the statement. If i can just get one, i can hopefully do the rest.
i have now:
strSQL2 = "SELECT Count(*) As Total FROM ptqr WHERE DateDiff('d','" & datein_now & "','" & dateclosed &"')< 1 "
but i get an error: Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access 97 Driver] Data type mismatch in criteria expression.
/asp/ford_tsb/pscs/reports/charts/Chart5.asp, line 40
I have a sql select statement that I would like to place in an include file.
The SQL select statement is fed variables from the page. For Instance Code:
<% Dim manuID, CatID manuID=6 CatID="'part','processor'"
Dim objRS Set objRs = Server.Createobject("ADODB.Recordset") objRs.Open "SELECT this, that, the other FROM TABLE WHERE Manufacturer='"& manuID & "' and Category in ("& catID &")", objCn, 1, 3 %>
The recordset is used later in the page via a sub procedure. What I did was move the code from DIM objRS to the closing bracket to my "connections" include file and then the sub stopped working. The sub simply displays the results of the recordest in a table.
Got a slight issue with a SQL SELECT statement n the slight issue being it kicking a error.
sql = "SELECT O2, Vodafone, Orange, T-Mobile, details1, details2, details3, details4, details5, details6, Type, Price, SimcardsID, Make, Model FROM Simcards"
Thats my SQL statement and the error is:
[MySQL][ODBC 3.51 Driver][mysqld-3.23.49-nt]Unknown column 'T' in 'field list'
I tried stickin [] around the T-Mobile field and it then kicks:
[MySQL][ODBC 3.51 Driver][mysqld-3.23.49-nt]You have an error in your SQL syntax near '[T-Mobile], details1, details2, details3, details4, details5, details6, Type, Pr' at line 1
The line works nicely offline (access database) just not when uploaded.
Function SetAvgClass(val) If NOT isnull(val) Then Select Case cint(val) Case (val < 100) SetAvgClass = "belowexpected" Case (val > 100) SetAvgClass = "aboveexpected" Case 100 SetAvgClass = "expected" End Select Else SetAvgClass = "belowexpected" End If End Function
The only case that seems to be working correctly is thw case 100. am i using incorrect syntax for the > and < statements?
i got a field named register_date, its input a table named member when a user register in my system, What im trying to do is i want to display daily registration in seperate table, anyway the database im using is mdb file, and data type for register_date is data/time.
so below is my coding, but i can get the table to be displayed, can someone tell me what wrong with my coding? Code: