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.

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">$&nbsp;<%=MyRS("SALES_PRICE")%></td>


<%
     MyRS.MoveNext

     WEND

     MyRS.Close
     set MyRS = nothing

%>

Open in new window

LVL 24
DMTechGrooupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Set MyRS = Server.CreateObject("ADODB.RecordSet")


          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.
0
DMTechGrooupAuthor Commented:
The DB connection is in the include file

<!--#include file="sql/includes/SQL_SERVER_OR_CAFE_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.
0
Jayaraja JayaramanSharepoint Architect ConsultantCommented:
if you wanna use sharepoint list to store and retrieve data then there are couple of ways to do it.
1.linq
2.caml
3.rest webservices,
4.more....
and then for connecting to other databases you can use BCS and external list so you can stay inside sharepoint object model to query and display the list information
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Looks like your problem is how the define a connection to a SQL Server database, right?

Depending on SQL Server version and on the components that you are using you can find plenty of cases in this link http://www.connectionstrings.com/sql-server/

For example, if you are connecting through SQL Server native client to a SQL Server 2008 database with a SQL Server user, this should be the connection string:
Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Open in new window


Hope that helps you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DMTechGrooupAuthor Commented:
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?
0
DMTechGrooupAuthor Commented:
I will try these suggestions and open new if needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.