ASP SQL Server Connection -



ASP SQL Server Connection -

class="lang-vb prettyprint-override"> <% dim objconn set objconn = server.createobject("adodb.connection") objconn.connectionstring = "data source=123.123.12.123,1234;database=databasename;user id=usernm;password=abcd1234;" objconn.open dim mysql mysql = "select * [users] [user id]='1'" dim objrs set objrs = server.createobject("adodb.recordset") objrs.open(mysql, objconn) response.write objrs("fullname") objrs.close set objrs = nil objconn.close set objconn = nil %>

i want connect sql server database, read info , close connection. have studied examples , came this. not working. please guide me. going wrong?

class="lang-vb prettyprint-override">dim rs, dbconn function opendb() set dbconn = server.createobject("adodb.connection") dbconn.connectiontimeout = 300 dbconn.commandtimeout = 300 dbconn.open "data source=123.123.12.123,1234;database=databasename;user id=usernm;password=abcd1234;" end function function closedb() set rs = nil if ucase(typename(dbconn)) = "connection" dbconn.close set dbconn = nil end if end function function openrecordset(recset, tablename) phone call opendb() set recset = server.createobject("adodb.recordset") recset.open tablename, dbconn, 0, 1 end function function closerecordset(recset) set recset = nil phone call closedb() end function

then use

class="lang-vb prettyprint-override"><% phone call opendb() sql = "select mytable = 'that'" set rs = dbconn.execute(sql) if not rs.eof ' stuff! end if phone call closedb() %>

http://www.shiningstar.net/articles/articles/database/datafunctions.asp?id=aw

sql sql-server asp-classic connection-string

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -