Forum Moderators: open
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 :)
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();
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.