loop throught data in DSN connection - asp.net

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.

Related

How to publish an asp.net project with a connection to a DB2 database?

I'm developing a project in asp.net that contains a connection to a iseries db2 database; locally the project works because I already have the IBM iseries Access for Windows driver installed in the machine where the project is developed, the problem is when I want to publish it on a server, the connection to the database doesn't work, I suppose the error happens beacuse doesn't exist any driver in the server. What can I do to connect the project with the database if I want to host it on a server for example In Microsoft Azure?
Currently the code to connect with the database is similar to this:
string provider = "DataSource=xxx.xxx.xxx.xxx;userid=user;password=pass;";
iDB2Connection cnn = new iDB2Connection(provider);
string sentencia = "select * from DTA.Customer FETCH FIRST 20 ROWS ONLY";
iDB2Command cmd = new iDB2Command(sentencia, cnn );
iDB2DataReader drDB2;
cnn.Open();
drDB2 = cmd.ExecuteReader();
int i = 0;
while (drDB2.Read())
{
//Console.WriteLine(drDB2.GetString(i));
}
drDB2.Close();
cnn.Close();

how to connect teradata using HP UFT

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.

Cannot connect to Azure SQL DataWarehouse from RStudio using Active Directory Authentication

I am trying to connect to Azure SQL Datawarehouse using RStudio. The only Authentication that is setup on the warehouse is Active Directory Password Authentication. I tried using the below connection string.
connectionString="Data Source = abc.database.secure.windows.net; Authentication=Active Directory Password;
Initial Catalog=dbo; UID='UserName';
PWD= ;
It fails with "neither DSN nor SERVER keywork supplied" . And I dont want to set up a DSN as I am building a front end app and it must be portable.
I tried RODBC too ..but couldn't get much help with Active Dir Authentication.
I finally got to the bottom of this after a few deadends. A key step is updating your ODBC driver to ODBC Driver 17. The following works using Azure Active Directory authentication, which is slightly different to a consumer key/consumer secret but may achieve the same outcome (i.e. authentication without a SQL password).
library(DBI)
server <- "yourserver.database.windows.net"
database = "database-name"
con <- DBI::dbConnect(odbc::odbc(),
UID = rstudioapi::askForPassword("username"),
Driver="ODBC Driver 17 for SQL Server",
Server = server, Database = database,
Authentication = "ActiveDirectoryInteractive")
For integrated AD authentication the connection string should look like:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:{full qualified server name},1433;Database={dbname};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryIntegrated
For AD passoword authentication:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:{full qualified server name},1433;Database={dbname};Uid={your_user_name};Pwd={your_password_here};Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryPassword
Did you download the ADALSQL.DLL library https://www.microsoft.com/en-us/download/details.aspx?id=48742? required to connect to Azure AD. Also to double check the ODBC driver you use is 13.1 - correct?
If the recommendation indicated above (the ADALSQL.dll download) will not solve your problem, please create a customer case for "Azure AD authentication with SQL DB" and report it to SQL customer service.
This code works but a window appears:
library(DBI)
server <- "xxxxxxxx.database.windows.net"
database = "myDB"
con <- DBI::dbConnect(odbc::odbc(),
UID = "name#mycompany.com",
Driver="ODBC Driver 17 for SQL Server",
Server = server, Database = database,
Authentication = "ActiveDirectoryInteractive")

Connecting MS SQL DataBase To GODADDY host

I am new to uploading websites online, I have uploaded my website to Godaddy host and run perfectly but i don't know how to connect my MS Sql Data base and how to configure my connection string ! can any one help me or give me a tutorial of how doing this starting from a normal MS sql Database with normal connection string(Local DB and Local connection string) until uploading it online ?
Connecting to a sql server database on go daddy works the same way as connecting to any other Sql Server db from a .Net perspective.
Log in to your go daddy account to get the connection string info. There's even code samples in there for how to configure your connection string.
Alos, here's a link about .net connection strings in general
http://msdn.microsoft.com/en-us/library/jj653752(v=vs.110).aspx
One of the advantages of using MS SQL is that you can use the SqlClient native libraries, which are faster than ODBC, etc.
using System.Data;
using System.Data.SqlClient;
public class Demo {
public DataTable ConnectAndQuery() {
SqlConnection cn = new SqlConnection("Data Source=IP-GOES-HERE;Initial Catalog=YOUR-DATABASE-NAME-HERE;user id=DB-USER-HERE;password=DB-PASS-HERE;Connection Timeout=300");
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM TableName", cn);
DataSet results = new DataSet();
da.Fill(results);
return results;
}
}
I usually store my connection strings in the web.config. There's actually a specific section you can store them in, if you'd like. Here's an example of that:
http://msdn.microsoft.com/en-us/library/dx0f3cf2(v=vs.85).aspx

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.

Resources