Current location: Hot Scripts Forums » Programming Languages » ASP » SQL Query help needed.


SQL Query help needed.

Reply
  #1 (permalink)  
Old 06-05-09, 07:54 AM
angru angru is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes SQL Query help needed.

Im writtin' a program, a minor and very simple, for my exam. However, i have one database with three tables in it and have created relations between them.
now my problem is that I can search in the individual tables, but not in all of the through the relations.
My program looks as follows:

Code:
<%
Dim SoegeStreng, skjult, strCriteria, sqlsoeg
SoegeStreng=Request.Form("personnummer")
 
Set rs = Server.CreateObject("ADODB.Recordset")
strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\ieusr2\users$\XXXXXX\XXXXXXX\writeaccess\databace.mdb"
 
sqlsoeg = "SELECT * FROM Patientoplysning WHERE Personnummer LIKE '%" & SoegeStreng & "%'" 
AND
sqlsoeg = "SELECT * FROM Sygdom WHERE Personnummer LIKE '%" & SoegeStreng & "%'"
 
rs.Open sqlsoeg, strDSN
 
Response.write RecToTable(rs)
 
rs.Close 
 
set rs=nothing
%>
The Xs in the strDSN is replacesments from the original, because it is private.


Can anybody please help me, i don't know what to do

Last edited by digioz; 06-05-09 at 10:01 AM. Reason: Please use CODE tags.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-05-09, 08:12 AM
CreativeClans CreativeClans is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I don't know ASP, but the query to join the two tables should be something like:
Code:
SELECT * 
FROM Patientoplysning p
INNER JOIN Sygdom s
ON p.Personnummer = s.Personnummer
WHERE Personnummer LIKE '%" & SoegeStreng & "%'"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-05-09, 08:16 AM
angru angru is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
SQL Query help needed.

dunno if Im really stupid, but it doesn't work..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-05-09, 08:33 AM
CreativeClans CreativeClans is offline
Newbie Coder
 
Join Date: Jun 2009
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I'm sure you're not stupid, and I told you I don't know ASP, so maybe what I wrote isn't correct.
But... what does "doesn't work" mean? An error? No result? A different result from what you expected?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-05-09, 08:36 AM
angru angru is offline
New Member
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
It gives me an error 500, and i think that means a code error.. so no result, it will not even show the pagde..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic where section of sql query soloWebDev Script Requests 3 01-31-08 03:48 PM
SQL db - custom insert and select query app needed ATS16805 ASP.NET 1 06-24-05 05:38 PM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM
change my field in this example sal21 ASP 3 07-14-03 03:49 AM


All times are GMT -5. The time now is 05:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.