Forum Moderators: open

Message Too Old, No Replies

Newbie questions about .net and mssql

I need to know

         

TheDave

8:59 am on May 3, 2004 (gmt 0)

10+ Year Member



What is the major difference between classic ASP and .NET? I've just upgraded our server to Windows 2003, and according to our hosting plan it comes with .NET Framework (1.1) support including ASP.NET and ADO.NET - in reality, as a basic online shop, what does this mean to me? Does it increase site speed, are there new programming methods I need to learn to get the most out of it? Basically, how can I fully benefit from this upgrade? Even a "Hello World" sample or something showing the difference would be great.

Second question, the upgrade also comes with MS SQL, but I have no idea how to connect to the database - and I'm kind of embarrased to ask. As far as my understanding goes - and this is limited because whenever I see SQL I shudder (I don't know why it must have really confused me at an early age ;)) - the database is on it's own server which you connect to and issue with commands to create your tables, add/retrieve records etc. Is this a correct understanding? Second SQL *shudder* question is, what are the practical steps I would need to take to change a web with an access database into one that uses SQL. Currently the main objects and methods I'm using are ADODB.Connection, ADODB.Recordset, occasional use of ADODB.Command, and despite my constand shuddering I do understand the Structured Query Language side of things, although so far I've only used dabblings of it.

I know these questions may sound dumb, and maybe even completely illogical, but that's why I said Newbie questions ;) Set me straight! thanks :)

Easy_Coder

1:22 pm on May 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The differences are plenty and I'd suggest a couple of books to get you going. If your thinking of heading down the c# route Beginning C# by Karli Watson is a good book. I'm sure some others here can recommend some vb.net books to get you going in that direction too.

One of the more important differences is that ASP is late bound and interpretted. vb.net or c# for example are both strongly typed. You'll also find that debugging code is so much smoother in the .net world then in asp. Unless you were writing com objects which you could easily debug in vb6 or something debugging asp can be quite a chore.

Here's a sample to connect to your sql db with c#. This method returns a SqlDataReader...


using System;
using System.Data;
using System.Data.SqlClient;
public class TestClass
{
private string _startDate;
private string _endDate;

/* start date property */
public string StartDate
{
get
{
return _startDate;
}
set
{
_startDate = value;
}
}

/* end date property */
public string EndDate
{
get
{
return _endDate;
}
set
{
_endDate = value;
}
}

public SqlDataReader TestReport()
{

/* Create a DataBase Connection */
SqlConnection reportCNN = new SqlConnection(user id=username; password=password; initial catalog=database; data source=machine);

/* Create a SqlCommand */
SqlCommand reportCMD = new SqlCommand("SprocName", reportCNN);
reportCMD.CommandType = CommandType.StoredProcedure;

// Start Date
SqlParameter _reportStart = new SqlParameter("@i_vStartDate", SqlDbType.VarChar, 25);
_reportStart.Value = _startDate;
reportCMD.Parameters.Add(_reportStart);

// End Date
SqlParameter _reportEnd = new SqlParameter("@i_vEndDate", SqlDbType.VarChar, 25);
_reportEnd.Value = _endDate;
reportCMD.Parameters.Add(_reportEnd);

/* Open the connection */
reportCNN.Open();

/* Get the report */
SqlDataReader reportDR = reportCMD.ExecuteReader();

/* populate the Count based on the current state */
_count = this.ReportCount("cspGetUnfilteredReferralCount");

/* Return the Report */
return reportDR;

}
}

You can bind the results very easily to a DataGrid for example...


TestClass oTest = new TestClass();
oTest.StartDate = "4/1/2004 12:00:00 AM";
oTest.EndDate = "5/1/2004 12:00:00 AM";

SqlDataReader oResults = oTest.TestReport();
DataGrid.DataSource = oResults;
DataGrid.DataBind();

raywood

2:12 pm on May 3, 2004 (gmt 0)

10+ Year Member



The .NET framework is essentially a class library that compiles as an intermediate run-time program. It's not an in-line scripting language. You can use just about any programming language you like with it. C++, C#, J#, VB, etc. If you've been doing ASP, then moving to VB.NET will be the easiest one for you.

There are lots of .NET sites on the web where you can find everything from tutorials to advanced techniques. It's a steep learning curve, but you can do it. Once you get even halfway good at it, you'll find your site much easier to program, debug, and maintain, and much more powerful.

You'll need a good IDE. I like Visual Studio, but ASP.NET Web Matrix is pretty good too and, it's free. You can get it from the microsoft .NET site.

TheDave

11:00 pm on May 3, 2004 (gmt 0)

10+ Year Member



Thanks for your replies, they were very helpful. I may be back with some more questions, but for now I'm off to do some research and learning