I have been developing an ASP.NET application. I want to integrate Classic ASP file(.asp) in this application.
In a .asp file I have to fetch data from SQL Server 2008 r2 database.
For this I have created db and rs object. I have passed ConnectionString in db.Open function. But I am getting no output for this code.
Following is my code
set db = Server.CreateObject("ADODB.Connection")
db.Open "provider=SQLNCLI10;Data Source=HP-PC\SQLEXPRESS;Initial Catalog=RMToday;Persist Security Info=True;"
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "select * from RMToday.dbo.[Current]",db
if not rs.EOF Then
response.Write(rs("DayClosed"))
End If
I have searched in stackoverflow.com and got some related questions, answer.
I can not understand the wrong in this code.
Thanks in advance
Related
I am trying to do feasibility of Teradata SQL Assistant using UFT.
Please help me to start and understanding this, since i am new to DB Validation.
Also i checked in internet how to connect DB using UFT i Found below code
'Create ADODB connection object
Set objConnection = CreateObject("ADODB.Connection")
'Create Recordsetobject
Set objRecordSet = CreateObject("ADODB.Recordset")
'Connect to DB using provider and server
objConnection.open "provider=sqloledb;Server=;User Id=;
Password=;Database=;Trusted_Connection=Yes"
'Write the SQL Query
sqlQuery="Select * from emp"
'Execute the query
objRecordSet.open sqlQuery, objConnection
'Display output
value = objRecordSet.fields.item(0)
msgbox Value
objRecordSet.Close
objConnection.Close
Set objConnection = Nothing
Set objRecordSet = Nothing
My team is connecting through Teradata.net not odbc connection, Will this code will work ? if not how to connect and retrieve data from teradata.
Thanks in advance,
Abu.
I am trying to connect to sql express db and inserting record to one of the table inside it using following code.
set conn=Server.CreateObject("ADODB.Connection")
SQL_Conn_STRING = "Driver={SQL Server};Server=(local);Database=classic_asp_poc;uid=my-domain\username;pwd=my password"
conn.Open SQL_Conn_STRING
Response.Write("con open")
I am getting error on open connection. Is there any problem in my connection string?
If you're using mssql express, you need to add \SQLEXPRESS to your database address/ip, so in your example you would use Server=(local\SQLEXPRESS)
You're using an odbc connection string. OLEDB or native client strings are the preferred method eg
SQL_Conn_STRING = "Provider=sqloledb;Data Source=local\SQLEXPRESS;Initial Catalog=classic_asp_poc;User Id=my-domain\username;Password=my password"
See this easy to remember link for more examples
http://www.connectionstrings.com/sql-server/
I have a classic asp application (ASP 3.0 running on Windows 2000/IIS 5.0) which allows users to write custom SQL queries to fetch data from the database (Oracle 10g), more like SQL Developer. Sometimes users write complex queries which runs indefinitely, though the user would click the back button to go back to previous page, the query might still run on the database. Now users are requesting they be given a functionality to kill the query on a click of a button.
I am beginner in asp, so I am not sure if this is possible in asp. We are using ADODB.RecordSet object to fetch the data using RecordSet.Open and RecordSet.GetRows. Please advise if this is achievable in classic asp.
Set connection = Server.CreateObject("ADODB.Connection")
connection.Open DATA_SOURCE, LOGON_ID, PASSWORD
Set resultset = Server.CreateObject("ADODB.Recordset")
Dim sql
sql="select sysdate from dual"
resultset.Open sql, connection
Dim DBData
DBData = resultset.GetRows(NUMROWS)
resultset.close
connection.close
Set resultset = Nothing
Set connection = Nothing
Try this
arrayRs = resultset.GetRows()
if arrayRs(0,0)<> "" then
response.write(arrayRs(0,0))
end if
Or you can try a loop when you are fetching more than one field
I've created an application using ASP.NET with Access DB, now I found somee.com who support only SQL Server DBs, so Now I must convert my Access DB to SQL Server DB.
Is there any tool who can do the trick ?
This is some code I'm using in my web application :
Public Shared Function conecter() As OleDbConnection
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & System.AppDomain.CurrentDomain.BaseDirectory & "/Learning.mdb")
MyConnexion.Open()
Return MyConnexion
End Function
Public Shared Function lecture(ByVal requete As String) As OleDbDataReader
Dim Mycommand As OleDbCommand = conecter().CreateCommand()
Mycommand.CommandText = requete
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader()
Return myReader
End Function
In this case, If I convert my database I must change the OleDbConnexion and other things or I can just leave them like that ?
Your connection string will need to change. Connectionstrings.com is a good resource for this if you're having problems figuring out how to set up a SQL connection string.
For upward migration, take a look at the Access Upsize Wizard - this link is for 2002 since I'm not sure what access version you have.
If for some reason you do not have sufficient access to your SQL database to handle an upsize directly, you'll likely need to just generate the database schema and knock out a bit of migration code.
If you have access 2007, there is inbuilt option convert access database to SQL other wise there are somany tools available for free.
bullzip free converter
Try MUST
It was developed by a colleague of mine (we designed the website: www.upsizing.co.uk).
It does a fair bit more than the MS tools.
I am getting an error when running this classic asp script:
Dim DB_CONNECTIONSTRING, rs, iRecordCount, strSQL
DB_CONNECTIONSTRING = "Provider=SQLOLEDB;Data Source=localhost;Initial Catalog=employee;Trusted_Connection=yes;"
strSQL = "SELECT * FROM EmployeeProfiles"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, DB_CONNECTIONSTRING, adOpenStatic, adLockReadOnly, adCmdText
The message I am getting is (the server does exsist):
Microsoft OLE DB Provider for SQL
Server error '80004005'
[DBNETLIB][ConnectionOpen
(Connect()).]SQL Server does not exist
or access denied.
\Default.asp, line 13
I see you're using Trusted_Connection=yes in your connection string. That means that whatever identity ASP is running under will try to connect to the database server using Windows authentication. The actual identity the web server uses depends on the platform and setup (usually IUSR_Foo).
To test out if this is the issue, try using temporarily replacing the connection string with one that uses SQL authentication. If this is the issue, you may want to either configure the web server to run the ASP under a different user account which has been granted database access (preferred) or give the current web server's identity access to the database. Or you can stick with SQL authentication, of course.
Either the server you're running the ASP on doesn't have a running database server, or the database server should have an instance name. One common mistake is to forget to add the SQLEXPRESS instance name for SQLExpress installs.