DMTechGrooup
asked on
Sharepoint 2013 - Query a SQL DB to pull information
On our current .asp intranet site we query information from several SQL DB's such as daily lunch menu, MTD/YTD company sales, open orders, etc.
We are in the process of changing to Sharepoint and would like to pull the same information. I find questions on how to query the Sharepoint DB but I need to query other DB's
Thanks for any help.
We are in the process of changing to Sharepoint and would like to pull the same information. I find questions on how to query the Sharepoint DB but I need to query other DB's
Thanks for any help.
DIM strSQLQuery, strITEM3, strMENUCHANGED, strITEM2
'
%>
<!--#include file="sql/includes/SQL_SERVER_OR_CAFE_DATABASE.asp"-->
<%
'
'
'END OF SETUP
%>
<center><table width="60%" border="1" cellspacing="3" cellpadding="3">
<%
strSQLQuery = "SELECT DAILY_MENU.MENU_DATE, MENU_ITEMS.MENU_ITEM AS ITEM1, MENU_ITEMS_1.MENU_ITEM AS ITEM2, MENU_ITEMS_2.MENU_ITEM AS ITEM3, " &_
"DAILY_MENU.SALES_PRICE, { fn DAYNAME(DAILY_MENU.MENU_DATE) } AS [DAY], DAILY_MENU.ID, DAILY_MENU.MENU_CHANGED, DAILY_MENU.CHANGED " &_
"FROM DAILY_MENU LEFT OUTER JOIN MENU_ITEMS MENU_ITEMS_2 ON DAILY_MENU.MENU_ITEM_ID_3 = MENU_ITEMS_2.MENU_ID LEFT OUTER JOIN "&_
"MENU_ITEMS MENU_ITEMS_1 ON DAILY_MENU.MENU_ITEM_ID_2 = MENU_ITEMS_1.MENU_ID LEFT OUTER JOIN MENU_ITEMS ON "&_
"DAILY_MENU.MENU_ITEM_ID_1 = MENU_ITEMS.MENU_ID " &_
"WHERE (DAILY_MENU.MENU_DATE = { fn CURDATE() }) ORDER BY DAILY_MENU.MENU_DATE"
Set MyRS = Server.CreateObject("ADODB.RecordSet")
Set MyRS = dli.Execute(strSQLQuery)
WHILE NOT MyRS.EOF
%>
<tr><td width="10%" align="center" valign="middle"><%=UCASE(MyRS("DAY"))%></td>
<%
if MyRS("CHANGED") = "Y" then
%>
<td width="15%" align="center" valign="middle" bgcolor="#FFFFCC"><%=MyRS("MENU_DATE")%></td>
<%
else
%>
<td width="15%" align="center" valign="middle"><%=MyRS("MENU_DATE")%></td>
<%
End if
%>
<td width="55%" align="center" valign="middle"><%=MyRS("ITEM1")%>
<%
if MyRS("ITEM2") <> "" then
strITEM2=", " & MyRS("ITEM2")
else
strITEM2 = ""
end if
%>
<%=strITEM2%>
<%
if MyRS("ITEM3") <> "" then
strITEM3=", " & MyRS("ITEM3")
else
strITEM3 = ""
end if
%>
<%=strITEM3%></td>
<td width="10%" align="center" valign="middle">$ <%=MyRS("SALES_PRICE")%></td>
<%
MyRS.MoveNext
WEND
MyRS.Close
set MyRS = nothing
%>
ASKER
The DB connection is in the include file
<!--#include file="sql/includes/SQL_SER VER_OR_CAF E_DATABASE .asp"-->
But I do not know how to do this type of thing in SharePoint. I took a page and added code and all that but is just displayed my code and not run it. So I don't know where to start.
I am pretty new to SharePoint.
<!--#include file="sql/includes/SQL_SER
But I do not know how to do this type of thing in SharePoint. I took a page and added code and all that but is just displayed my code and not run it. So I don't know where to start.
I am pretty new to SharePoint.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry if I seem frustrating or such.. But does anyone have an example .aspx or something I can look at to see. Or if I were to show you what .asp I am using you can be more specific how you would accomplish the same thing?
ASKER
I will try these suggestions and open new if needed.
Set MyRS = dli.Execute(strSQLQuery)
How MyRS knows which DB to query? From Server connection right?
So you should to connect to others DB as you are connecting to this one but need to change the connection string for access to the correct database.