how to connect teradata using HP UFT - teradata

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.

Related

loop throught data in DSN connection

I set Netsuite (our business management program) up for web service and ODBC connection.
I configure the ODBC in my server to connect to their web service via system DSN and file DSN. I tested the connection with user id and password and it worked.
But now in my VS2013 my ASP.net (VB) page, I can't get to loop through the records in any table:
Dim cn As OdbcConnection
cn = New OdbcConnection("DRIVER=CData ODBC Driver for NetSuite 2015;dsn=odbc1;uid=myemail.com;pwd=mypassword")
cn.Open()
Dim cmdstring33 As String = "select * from CustomList"
Dim cmd33 As New OdbcCommand(cmdstring33, cn)
Dim rds33 = cmd33.ExecuteReader
'While rds33.Read
' Response.Write(rds33("Internalid"))
'End While
cn.Close()
But i get the following error:
ERROR [HY000] An account must be specified in order to login to NetSuite.
in "Dim rds33 = cmd33.ExecuteReader"
But the account works when I test the connection in ODBC administration window
what am I doing wrong?
Thanks for any advice
With the ODBC .NET Managed Provider, you should either specify the DSN you wish to use:
cn = New OdbcConnection("DSN=odbc1")
OR you should specify the ODBC Driver and the connection string:
cn = New OdbcConnection("DRIVER=CData ODBC Driver for NetSuite 2015;accountid=...;password=*****;roleid=3;user=...;version=2013_1")
where you fill in the connection string values based on the documentation provided for the Driver.
*Note that our Drivers (CData software) don't require user/password by default, so you don't need to specify the uid or password when using a DSN.

ADODB Connection String not working in Classic ASP

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

classic asp async sql execution

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

Database error in classic ASP application

I have a classic ASP app which connects to an access database, I receive the following error when I try to access a page which connects to the database:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x1b48 Thread 0x1970 DBC 0x1948024 Jet'.
/gasket.inc, line 24
Here is my gasket.inc file:
<%
'include file for gasket table database object
'Dimension variables
Dim adoConG 'Database Connection Variable
Dim strConG 'Holds the Database driver and the path and name of the database
Dim rsGasket 'Database Recordset Variable
Dim strAccessDBG 'Holds the Access Database Name
Dim strSQLG 'Database query sring
'Initialise the strAccessDB variable with the name of the Access Database
strAccessDBG = "\\MyServer\databases\gaskets\gaskets.mdb"
'Create a connection object
Set adoConG = Server.CreateObject("ADODB.Connection")
'Database connection info and driver
strConG = "DRIVER={Microsoft Access Driver (*.mdb)};uid=admin;pwd=; DBQ=" & strAccessDBG
'Set an active connection to the Connection object
'adoConG.Open "DSN=Gaskets"
adoConG.Open strConG
'Create a recordset object
Set rsGasket = Server.CreateObject("ADODB.Recordset")
%>
Does that admin user require permission to access the database? Or am I missing something else which is obvious?
If you're using a UID/PWD for this, that would have to match an account that was used to lock the database, or a machine/domain account that will have write to/lock permissions to the db. Also, keep in mind that classic ASP is running under the IUSR_ account by default - sometimes this account must have write access to the directory/file containing the Access db.

SQL Connection Forcibly Closed

I'm having difficulty with an SQL query against Server 2008 from IIS7. I have a VB.NET class library which runs an update statement. The underlying code used to create the connection hasn't changed, but suddenly the query is failing in our testing and development environments. It does, however, still work against the same server/database using the slightly older code in our production environment.
I've tried setting the connection timeout in the web.config and I'm at a loss to explain the cause.
The basic structure of the query is:
Dim conn = New SqlConnection()
conn.ConnectionString = "Data Source=someserver\sqlexpress2008;Initial Catalog=DatabaseName;User ID=sa;Password=pass"
conn.Open()
Using cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "UPDATE ..."
cmd.Parameters.AddWithValue("#UName", user.name)
cmd.ExecuteNonQuery() 'fails with error
End Using
The error is:
A transport-level error has occurred when sending the request to the
server. (provider: TCP Provider, error: 0 - An existing connection was
forcibly closed by the remote host.)
I've tried restarting IIS and the SQL server and I'm totally out of ideas. I just need a fix
You need to open the connection before calling SqlCommand.ExecuteNonQuery(). You do this by calling SqlConnection.Open().
Dim conn = New SqlConnection()
conn.ConnectionString = "Data Source=someserver\sqlexpress2008;Initial Catalog=DatabaseName;User ID=sa;Password=pass"
Using cmd As SqlCommand = conn.CreateCommand()
cmd.CommandText = "UPDATE ..."
cmd.Parameters.AddWithValue("#UName", user.name)
conn.Open()
cmd.ExecuteNonQuery() 'fails with error
conn.Close()
End Using
Also, ensure you database isn't in single user mode.
This helped another person who was stuck recently. You could examine the problem from the database server by setting up a SQL Server Profiler.
You can find lots of info about SQL Profiler by just googling around. Here's a site with a video that might help you get started. For starters, you would be able to see if the request is even reaching the database server.
This was a nightmare to track down. It turned out to be cause by a horrible quirk in VB.NET. Nullable datetimes seem to be coerced to DateTime.MinValue, which resulted in a DateTime.MinValue being inserted into an sql datetime. The fix was to check for either !property.HasValue && property.Value != DateTime.MinValue when setting the parameters for the command.
This is a network-level error. The database server is killing the connection for some reason. In order to troubleshoot this, I would open a connection using SSMS to the DEV and TEST servers and make sure that I can run simple queries w/o problems. It's unlikely that the issue is your library since you would be getting timeout or some other kind of errors.
as Lcarus, said, database server is killing the connection for unknown reason.
you can check the logs, to verfiy. Log path will be C:\Program Files\Microsoft SQL Server\<your instance>\MSSQL\LOG
from MSDN Blog MSDN Blog
this will occur when A connection is taken from the connection pool,
the application does not know that the physical connection is gone, an
attempt to use it is done under the assumption that the physical
connection is still there.

Resources