For Programmers: Free Programming Magazines  


Home > Archive > ASP > May 2006 > Moving on to SQL Express









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Moving on to SQL Express
Christopher Brandsdal

2006-05-12, 7:55 am

Hi!

Just had to convert a asp website I have from Acces to MS SQL Express.

Is this an OK way to connect to the database?
It works great, but I just wanted to know if this is the best way to do
it....
The code runs on the same surver as the sql express server.


AdoConnection = "Provider=SQLOLEDB.1; Data Source=xxx.xx.xxx.xxx;Initial
Catalog=DatabaseName;Persist Security Info=True;User ID=sa;Password=Pass"

ConnectString = AdoConnection
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString

sqlBruker = "SELECT Fornavn FROM Bruker"
Set rsBruker = Server.CreateObject("ADODB.Recordset")
rsBruker.Open sqlBruker, conn, 3, 3
Response.Write(rsBruker("Fornavn"))
rsBruker.close
set rsBruker=nothing

Best regards,
Christopher Brandsdal


Ray Costanzo [MVP]

2006-05-12, 7:55 am

Close. Explicitly creating a recordset is an extra step that isn't
required. Check out:

http://www.aspfaq.com/show.asp?id=2424
http://www.aspfaq.com/show.asp?id=2191

Ray at work

"Christopher Brandsdal" <christopher@valdres.no> wrote in message
news:uwXoV7adGHA.4900@TK2MSFTNGP02.phx.gbl...
> Hi!
>
> Just had to convert a asp website I have from Acces to MS SQL Express.
>
> Is this an OK way to connect to the database?
> It works great, but I just wanted to know if this is the best way to do
> it....
> The code runs on the same surver as the sql express server.
>
>
> AdoConnection = "Provider=SQLOLEDB.1; Data Source=xxx.xx.xxx.xxx;Initial
> Catalog=DatabaseName;Persist Security Info=True;User ID=sa;Password=Pass"
>
> ConnectString = AdoConnection
> Set conn = Server.CreateObject("ADODB.Connection")
> conn.open ConnectString
>
> sqlBruker = "SELECT Fornavn FROM Bruker"
> Set rsBruker = Server.CreateObject("ADODB.Recordset")
> rsBruker.Open sqlBruker, conn, 3, 3
> Response.Write(rsBruker("Fornavn"))
> rsBruker.close
> set rsBruker=nothing
>
> Best regards,
> Christopher Brandsdal
>



John Blessing

2006-05-15, 7:56 am

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:uHMMXacdGHA.4912@TK2MSFTNGP05.phx.gbl...[color=darkred]
> Close. Explicitly creating a recordset is an extra step that isn't
> required. Check out:
>
> http://www.aspfaq.com/show.asp?id=2424
> http://www.aspfaq.com/show.asp?id=2191
>
> Ray at work
>
> "Christopher Brandsdal" <christopher@valdres.no> wrote in message
> news:uwXoV7adGHA.4900@TK2MSFTNGP02.phx.gbl...


Don't you think it is a touch dangerous connecting as System Administrator?

Create another user, assign appropriate permissions, use that instead.

--
John Blessing

http://www.LbeHelpdesk.com - Help Desk software priced to suit all
businesses
http://www.room-booking-software.com - Schedule rooms & equipment bookings
for your meeting/class over the web.
http://www.lbetoolbox.com - Remove Duplicates from MS Outlook, find/replace,
send newsletters


Christopher Brandsdal

2006-05-31, 6:56 pm

Thanks! Worked great :)


"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> skrev i
melding news:uHMMXacdGHA.4912@TK2MSFTNGP05.phx.gbl...
> Close. Explicitly creating a recordset is an extra step that isn't
> required. Check out:
>
> http://www.aspfaq.com/show.asp?id=2424
> http://www.aspfaq.com/show.asp?id=2191
>
> Ray at work
>
> "Christopher Brandsdal" <christopher@valdres.no> wrote in message
> news:uwXoV7adGHA.4900@TK2MSFTNGP02.phx.gbl...
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com