?
Solved

Classic ASP to ASP.NET help - SQL Connection

Posted on 2014-09-04
3
Medium Priority
?
268 Views
Last Modified: 2014-11-19
I am sure someone can rewrite this in about 10 seconds.. I am trying to learn how to change from a classic ASP site to ASP.NET..

I have played with Visual Studio to do some but I am still not sure how to just convert this code to ASP.NET.  This is on an Intranet site.

All help is appreciated.

<% @Language = "VBScript" %>
<%
DIM YRTTL
DIM MNTTL
DIM MNAVG
DIM INValue(12)
    dim dli
    dim MyRS
    dim MySQL


Set dli = Server.CreateObject("ADODB.Connection")
'
'Open the SQL Connection with the following login information
dli.Open("Provider=SQLOLEDB;Data Source=DLI1;Initial Catalog=DLI; User ID=NET;Password=NET;")
'
Set MyRS = Server.CreateObject("ADODB.RecordSet")

    MySQL = "SELECT SHIPPER.SHIPPED_DATE, SUM(SHIPPER_LINE.SHIPPED_QTY * SHIPPER_LINE.UNIT_PRICE) AS TTL, " & _
       "YEAR(SHIPPER.SHIPPED_DATE) AS Y, MONTH(SHIPPER.SHIPPED_DATE) AS M " & _
       "FROM SHIPPER INNER JOIN SHIPPER_LINE ON SHIPPER.PACKLIST_ID = SHIPPER_LINE.PACKLIST_ID " & _
       "GROUP BY SHIPPER.SHIPPED_DATE HAVING (YEAR(SHIPPER.SHIPPED_DATE) = '" & Year(Date) & "')"

set MyRS = dli.Execute(MySQL)
 If MyRS.EOF and MyRS.BOF then
 	Response.Write "No WO Exists!"
 	Err=True
 Else
 	DIM X
 	DIM Z
 	MYRS.MOVEFIRST
 	While Not MyRS.EOF
 		'RESPONSE.WRITE MYRS("TTL")
 		INValue((MYRS("M")))=INVALUE((MYRS("M"))) + CSNG(MYRS("TTL"))
 		YRTTL=YRTTL + CSNG(MYRS("TTL"))
 		MYRS.MOVENEXT
 	WEND
 	FOR X=1 TO 12
 		IF INValue(X)<>0 THEN
 			Z=Z+1
 			MNAVG=YRTTL/Z
 		END IF
 	NEXT
 END IF

 YRTTL = FormatNumber(YRTTL, 0)
 MNAVG = FormatNumber(MNAVG, 0)
 'YRTTL=YRTTL/1000000
 'MNAVG=MNAVG/1000000
 MNTTL=INVALUE(MONTH(NOW))
 MNTTL = FormatNumber(MNTTL, 0)

 %>
 <p>&nbsp;</b></font><font size="2" face="Times New Roman"><p style="word-spacing: 0; line-height: 100%; margin: 0">
 	<b><font size="5">Current Sales</font></b>
                 <p style="word-spacing: 0; line-height: 100%; margin: 0">&nbsp;<p style="word-spacing: 0; line-height: 100%; margin: 0">
 		<font size="4"><%=MonthName(Month(Date)) & " Sales:      $ " & MNTTL%></font>
     <p style="word-spacing: 0; line-height: 100%; margin: 0">
 	&nbsp;<p style="word-spacing: 0; line-height: 100%; margin: 0">
 	<font size="4"><%="Monthly Avg:  $ " & MNAVG%></font>
     <p style="word-spacing: 0; line-height: 100%; margin: 0">
 	&nbsp;<p style="word-spacing: 0; line-height: 100%; margin: 0">
 	<font size="4"><%=year(date) & " Total:     $ " & YRTTL%></font>
     </font><p style="word-spacing: 0; line-height: 100%; margin: 0">
					<br />

Open in new window

0
Comment
Question by:DMTechGrooup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 40304989
classic asp and asp .net are two completely technologies, and there is no "magic" way of converting the code over. i suggest you reconsider the WHY of converting to .NET, as classic asp is still a very viable technology, and continues to have its of End of Life support pushed back (I think the last I heard it was pushed back until 2023). If you're thinking of converting just to further your own knowledge, then by all means, go for it, but if it's because classic asp is an old out-dated language, well, then I would respectfully disagree with you :)

getting back to your question, are you having specific problems you're running into converting the code over? Usually here on EE you won't find too many experts that'll just write out code for you without seeing some kind of attempt on your end. If you could show us what you have already then it'll be easier for us to help.
0
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 40305732
Well, I don't fully agree that you should stick with asp.  Windows server supports classic asp and has an end of life of 2018 and extended support through 2023.  http://support.microsoft.com/lifecycle/search/default.aspx?sort=PN&alpha=Windows+server&Filter=FilterNO.    Working backwards, you would want a new non classic asp site to be running in perfect condition by 2022  That may mean starting in2021.  If you are starting something now, chances are it will be live in 2015.  That 6 years will hit you faster than you think.

Everything is going to an MVC format and learning that is just one piece of the puzzle in addition to .NET.  However, you can write .NET using asp code.  Try putting your asp code as and try using an extension of aspx instead of asp and see what happens.  That is not optimal or correct, but it may get you going quicker.

http://www.asp.net/mvc/tutorials
http://www.asp.net/get-started
http://www.w3schools.com/aspnet/
0
 
LVL 24

Author Comment

by:DMTechGrooup
ID: 40306012
Well here is what I wrote just trying to get something out of our DB.. its in grid view which is what I need.. Like the code above I am trying to get some numbers.. do some calculations then in the HTML display those variables.

<%@ Page Language="VB" %>

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta charset="utf-8" />
    <title></title>    
</head>
<body>
    <form id="form1" runat="server">   
     <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
                <Columns>
                    <asp:BoundField DataField="ROWID" HeaderText="ROWID" ReadOnly="True" SortExpression="ROWID" />
                    <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
                    <asp:BoundField DataField="SERIAL_NO" HeaderText="SERIAL_NO" SortExpression="SERIAL_NO" />
                    <asp:BoundField DataField="ACTIVATION_KEY" HeaderText="ACTIVATION_KEY" SortExpression="ACTIVATION_KEY" />
                    <asp:BoundField DataField="CONFIGURATION_KEY" HeaderText="CONFIGURATION_KEY" SortExpression="CONFIGURATION_KEY" />
                    <asp:BoundField DataField="INSTALL_DATE" HeaderText="INSTALL_DATE" SortExpression="INSTALL_DATE" />
                    <asp:BoundField DataField="LAST_CONVERT_DATE" HeaderText="LAST_CONVERT_DATE" SortExpression="LAST_CONVERT_DATE" />
                    <asp:BoundField DataField="DBVERSION" HeaderText="DBVERSION" SortExpression="DBVERSION" />
                    <asp:BoundField DataField="MAXIMUM_USERS" HeaderText="MAXIMUM_USERS" SortExpression="MAXIMUM_USERS" />
                    <asp:BoundField DataField="COMPANY_NAME" HeaderText="COMPANY_NAME" SortExpression="COMPANY_NAME" />
                    <asp:BoundField DataField="COMPANY_ADDR_1" HeaderText="COMPANY_ADDR_1" SortExpression="COMPANY_ADDR_1" />
                    <asp:BoundField DataField="COMPANY_ADDR_2" HeaderText="COMPANY_ADDR_2" SortExpression="COMPANY_ADDR_2" />
                    <asp:BoundField DataField="COMPANY_ADDR_3" HeaderText="COMPANY_ADDR_3" SortExpression="COMPANY_ADDR_3" />
                    <asp:BoundField DataField="COMPANY_CITY" HeaderText="COMPANY_CITY" SortExpression="COMPANY_CITY" />
                    <asp:BoundField DataField="COMPANY_STATE" HeaderText="COMPANY_STATE" SortExpression="COMPANY_STATE" />
                    <asp:BoundField DataField="COMPANY_ZIPCODE" HeaderText="COMPANY_ZIPCODE" SortExpression="COMPANY_ZIPCODE" />
                    <asp:BoundField DataField="COMPANY_COUNTRY" HeaderText="COMPANY_COUNTRY" SortExpression="COMPANY_COUNTRY" />
                    <asp:BoundField DataField="MFG_INTERFACE_USED" HeaderText="MFG_INTERFACE_USED" SortExpression="MFG_INTERFACE_USED" />
                    <asp:BoundField DataField="PART_UDF_LABELS" HeaderText="PART_UDF_LABELS" SortExpression="PART_UDF_LABELS" />
                    <asp:BoundField DataField="VEND_UDF_LABELS" HeaderText="VEND_UDF_LABELS" SortExpression="VEND_UDF_LABELS" />
                    <asp:BoundField DataField="CUST_UDF_LABELS" HeaderText="CUST_UDF_LABELS" SortExpression="CUST_UDF_LABELS" />
                    <asp:BoundField DataField="COMMISSION_SUPPORT" HeaderText="COMMISSION_SUPPORT" SortExpression="COMMISSION_SUPPORT" />
                    <asp:BoundField DataField="PURC_QUOTE_TYPE" HeaderText="PURC_QUOTE_TYPE" SortExpression="PURC_QUOTE_TYPE" />
                    <asp:BoundField DataField="XBAR_SUBGROUP_MIN" HeaderText="XBAR_SUBGROUP_MIN" SortExpression="XBAR_SUBGROUP_MIN" />
                    <asp:BoundField DataField="SD_SUBGROUP_MIN" HeaderText="SD_SUBGROUP_MIN" SortExpression="SD_SUBGROUP_MIN" />
                    <asp:BoundField DataField="CUR_SCHEDULE_ID" HeaderText="CUR_SCHEDULE_ID" SortExpression="CUR_SCHEDULE_ID" />
                    <asp:BoundField DataField="VALIDATE_LOOKUPS" HeaderText="VALIDATE_LOOKUPS" SortExpression="VALIDATE_LOOKUPS" />
                    <asp:BoundField DataField="TABLE_PATCH_LVL" HeaderText="TABLE_PATCH_LVL" SortExpression="TABLE_PATCH_LVL" />
                    <asp:BoundField DataField="TRIGGER_PATCH_LVL" HeaderText="TRIGGER_PATCH_LVL" SortExpression="TRIGGER_PATCH_LVL" />
                    <asp:BoundField DataField="PROGRAM_PATCH_LVL" HeaderText="PROGRAM_PATCH_LVL" SortExpression="PROGRAM_PATCH_LVL" />
                    <asp:BoundField DataField="DRAWING_FILE_PATH" HeaderText="DRAWING_FILE_PATH" SortExpression="DRAWING_FILE_PATH" />
                    <asp:BoundField DataField="DRAWING_LOCATOR" HeaderText="DRAWING_LOCATOR" SortExpression="DRAWING_LOCATOR" />
                    <asp:BoundField DataField="DRAWING_VIEWER" HeaderText="DRAWING_VIEWER" SortExpression="DRAWING_VIEWER" />
                    <asp:BoundField DataField="EURO_CURRENCY_ID" HeaderText="EURO_CURRENCY_ID" SortExpression="EURO_CURRENCY_ID" />
                    <asp:BoundField DataField="BARCODE_MULTI_JOB" HeaderText="BARCODE_MULTI_JOB" SortExpression="BARCODE_MULTI_JOB" />
                    <asp:BoundField DataField="WO_PRIORITY_PATH" HeaderText="WO_PRIORITY_PATH" SortExpression="WO_PRIORITY_PATH" />
                    <asp:BoundField DataField="SESSION_TIMELIMIT" HeaderText="SESSION_TIMELIMIT" SortExpression="SESSION_TIMELIMIT" />
                    <asp:BoundField DataField="VQ_DIRECTORY" HeaderText="VQ_DIRECTORY" SortExpression="VQ_DIRECTORY" />
                    <asp:BoundField DataField="VQ_DBNAME" HeaderText="VQ_DBNAME" SortExpression="VQ_DBNAME" />
                    <asp:BoundField DataField="VQ_ENABLED" HeaderText="VQ_ENABLED" SortExpression="VQ_ENABLED" />
                    <asp:BoundField DataField="VQ_QUERY_USE" HeaderText="VQ_QUERY_USE" SortExpression="VQ_QUERY_USE" />
                    <asp:BoundField DataField="CUST_PRICE_EFF_REQ" HeaderText="CUST_PRICE_EFF_REQ" SortExpression="CUST_PRICE_EFF_REQ" />
                    <asp:BoundField DataField="FILTER_AVAIL_TRACE" HeaderText="FILTER_AVAIL_TRACE" SortExpression="FILTER_AVAIL_TRACE" />
                    <asp:BoundField DataField="WFL_CMNT_PWD_REQ" HeaderText="WFL_CMNT_PWD_REQ" SortExpression="WFL_CMNT_PWD_REQ" />
                    <asp:BoundField DataField="SQLBASE_DATABASE_VERSION" HeaderText="SQLBASE_DATABASE_VERSION" SortExpression="SQLBASE_DATABASE_VERSION" />
                    <asp:BoundField DataField="PROJ_UDF_LABELS" HeaderText="PROJ_UDF_LABELS" SortExpression="PROJ_UDF_LABELS" />
                    <asp:BoundField DataField="DOCUMENT_DIRECTORY" HeaderText="DOCUMENT_DIRECTORY" SortExpression="DOCUMENT_DIRECTORY" />
                    <asp:BoundField DataField="ALLOW_EMAIL_DOC" HeaderText="ALLOW_EMAIL_DOC" SortExpression="ALLOW_EMAIL_DOC" />
                    <asp:BoundField DataField="SHOP_UDF_LABELS" HeaderText="SHOP_UDF_LABELS" SortExpression="SHOP_UDF_LABELS" />
                    <asp:BoundField DataField="AUDIT_REPORT_TIMES" HeaderText="AUDIT_REPORT_TIMES" SortExpression="AUDIT_REPORT_TIMES" />
                    <asp:BoundField DataField="DEF_OLDEST_INV_TYPE" HeaderText="DEF_OLDEST_INV_TYPE" SortExpression="DEF_OLDEST_INV_TYPE" />
                    <asp:BoundField DataField="VR_LIVE_UPDATES" HeaderText="VR_LIVE_UPDATES" SortExpression="VR_LIVE_UPDATES" />
                    <asp:BoundField DataField="VISUAL_USER_GROUP" HeaderText="VISUAL_USER_GROUP" SortExpression="VISUAL_USER_GROUP" />
                    <asp:BoundField DataField="SSO_ENABLED" HeaderText="SSO_ENABLED" SortExpression="SSO_ENABLED" />
                    <asp:BoundField DataField="DOC_UDF_LABELS" HeaderText="DOC_UDF_LABELS" SortExpression="DOC_UDF_LABELS" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=DLI1;Initial Catalog=DLI;Persist Security Info=True;User ID=NET;Password=NET" ProviderName="System.Data.SqlClient" SelectCommand="SELECT [ROWID], [ID], [SERIAL_NO], [ACTIVATION_KEY], [CONFIGURATION_KEY], [INSTALL_DATE], [LAST_CONVERT_DATE], [DBVERSION], [MAXIMUM_USERS], [COMPANY_NAME], [COMPANY_ADDR_1], [COMPANY_ADDR_2], [COMPANY_ADDR_3], [COMPANY_CITY], [COMPANY_STATE], [COMPANY_ZIPCODE], [COMPANY_COUNTRY], [MFG_INTERFACE_USED], [PART_UDF_LABELS], [VEND_UDF_LABELS], [CUST_UDF_LABELS], [COMMISSION_SUPPORT], [PURC_QUOTE_TYPE], [XBAR_SUBGROUP_MIN], [SD_SUBGROUP_MIN], [CUR_SCHEDULE_ID], [VALIDATE_LOOKUPS], [TABLE_PATCH_LVL], [TRIGGER_PATCH_LVL], [PROGRAM_PATCH_LVL], [DRAWING_FILE_PATH], [DRAWING_LOCATOR], [DRAWING_VIEWER], [EURO_CURRENCY_ID], [BARCODE_MULTI_JOB], [WO_PRIORITY_PATH], [SESSION_TIMELIMIT], [VQ_DIRECTORY], [VQ_DBNAME], [VQ_ENABLED], [VQ_QUERY_USE], [CUST_PRICE_EFF_REQ], [FILTER_AVAIL_TRACE], [WFL_CMNT_PWD_REQ], [SQLBASE_DATABASE_VERSION], [PROJ_UDF_LABELS], [DOCUMENT_DIRECTORY], [ALLOW_EMAIL_DOC], [SHOP_UDF_LABELS], [AUDIT_REPORT_TIMES], [DEF_OLDEST_INV_TYPE], [VR_LIVE_UPDATES], [VISUAL_USER_GROUP], [SSO_ENABLED], [DOC_UDF_LABELS] FROM [APPLICATION_GLOBAL]">
            </asp:SqlDataSource>
            <br />
        </p>
        <p>
        </p>
    

    
    
    </form>
</body>
</html>

Open in new window


I agree it's time to start moving away from ASP to newer tech.  I will look into MVC.. but I am a network admin who dabbles in programming so I have a basic understanding and with the help of places like this and the almighty google I usually figure it out.
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question