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:
<%
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:
<%
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!
AlexUse Option Strict on the top of your pages which will force you to code correctly first off. By declaring the types of each variable.
I will help more later.
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:
<%
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:
<%
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!
AlexUse Option Strict on the top of your pages which will force you to code correctly first off. By declaring the types of each variable.
I will help more later.