ajclifford
Programmer
Hi,
I've migrated from ASP Classic to ASP.NET but I'm having real trouble learning the new ADO.NET way of database programming. I used to use the following two functions for creating ASP Classic database connections:
And then display data to my ASP Classic pages with code like this:
How do I convert this process to ADO.NET? Help would be muchly appreicated, thanks!
Alex
I've migrated from ASP Classic to ASP.NET but I'm having real trouble learning the new ADO.NET way of database programming. I used to use the following two functions for creating ASP Classic database connections:
Code:
<%
Function CreateConn()
dim Connect
dim cnDB
Connect = "Provider=SQLOLEDB.1;Data Source=DBASESVR;Initial Catalog=Contractors;uid=user;pwd=pass"
Set cnDB = Server.CreateObject("ADODB.Connection")
cnDB.Open(Connect)
Set CreateConn = cnDB
End Function
Function SQLQuery(cnDB, queryString)
dim rsADO
Set rsADO = Server.CreateObject("ADODB.Recordset")
rsADO.ActiveConnection = cnDB
rsADO.Open(queryString)
Set SQLQuery = rsADO
End Function
%>
And then display data to my ASP Classic pages with code like this:
Code:
<%
dim cnDB
Set cnDB = CreateConnection
SqlCommandView = "SELECT ID, Name FROM Contacts WHERE ID=1"
Set RsView = SQLQuery(cnDB, SqlCommandView)
Dim DataVariable
DataVariable = RsView("Name")
%>
How do I convert this process to ADO.NET? Help would be muchly appreicated, thanks!
Alex