Create SQL connection using Install Script in InstallShield project - installshield

In InstallShiled setup project we have certain requirement that we need to validate any specific DataBase is exist or not on given SQL Server.
For that we are using below Install Script:
szADOConnObjID = "ADODB.Connection";
set pADOConnObj = CreateObject(szADOConnObjID);
szConnString = "driver={SQL Server};"; // For TLS 1.2 Only use driver={SQL Server Native Client 11.0};
szConnString = szConnString + "server=HPSDEV67;";
szConnString = szConnString + "Initial Catalog=master;";
szConnString = szConnString + "Integrated Security=True";
MessageBox("SQL Connection String: " + szConnString, INFORMATION);
try
MessageBox("Trying with Windows Authentication first", INFORMATION);
if (pADOConnObj.State==0)then
pADOConnObj.Open(szConnString);
MessageBox("Connection Success", INFORMATION);
endif;
catch
MessageBox("Windows Authentication Catch",INFORMATION);
MessageBox(Err.Description , SEVERE);
endcatch;
With above Install Script it gives below error:
---------------------------
Sample SQL Connect - InstallShield Wizard
---------------------------
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
---------------------------
OK
---------------------------
Any idea what am I doing something wrong here?

After digging in detail I found fix for this from here.
For Non-TLS 1.2
szConnString = "Provider=SQLOLEDB;"
szConnString = szConnString + "data source=SQLServerName;"
szConnString = szConnString + "Initial Catalog=master;"
szConnString = szConnString + "Integrated Security=SSPI"
For TLS 1.2
szConnString = "Provider=SQLNCLI11;"
szConnString = szConnString + "SERVER=SQLServerName;"
szConnString = szConnString + "database=master;"
szConnString = szConnString + "Trusted_Connection=Yes"
msgbox "SQL Connection String: " + szConnString, INFORMATION
For TLS 1.2 is best solution because it's working in both environment.

Microsoft released new driver MSOLEDBSQL early this year 2018 and will continue to provide updates on this driver only.
https://blogs.msdn.microsoft.com/sqlnativeclient/2018/03/30/released-microsoft-ole-db-driver-for-sql-server/

Related

How to establish a Microsoft azure databricks delta tables connection using spring boot just like mysql,sql server

Hi I want to establish a connection with the Microsoft azure databricks delta table inside my spring boot application.I have the cluster url,username and the password(token) of the delta table from which I need to pull the data to my application. Kindly shed some light on this
You can access cluster & underlying tables using the JDBC (see documentation). You need to get the corresponding driver, and add it to your application, and then just use normal JDBC API, like this:
String jdbcConnectPassthroughCluster = "jdbc:spark://<server-hostname>:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/0/xxxx-xxxxxx-xxxxxxxx;AuthMech=3;UID=token;PWD=";
String PATH = "<personal token>"
String JDBC_DRIVER = "com.simba.spark.jdbc.Driver";
String DB_URL = jdbcConnectPassthroughCluster + PAT;
Class.forName(JDBC_DRIVER);
System.out.println("Getting connection");
Connection conn = DriverManager.getConnection(DB_URL);
Statement stmt = conn.createStatement();
System.out.println("Going to execute query");
ResultSet rs = stmt.executeQuery("select * from table");
System.out.println("Query is executed");
int i = 0;
while(rs.next()) {
System.out.println("Row " + i + "=" + rs.getLong(1));
i++;
}
rs.close();
stmt.close();
conn.close();

Issue importing Excel into SQL using IIS App pool

I have written a web app in asp.net that will import data from an excel spreadsheet to SQL (code below). If I run it from VS on my local machine using IIS Express it works fine. However, when I deploy it as a web app on our Azure web server as an IIS App Pool, it is only importing part of the data from excel (16250 rows out of 73,000). I have the app pool set to enable 32 bit applications (the microsoft.ace.oledb library on that server is 32 bit). I found the last record it loaded in SQL (it only partially loaded the row) and moved that to the top of the excel spreadsheet and re-imported. That record imported fine this time but still only got partial import into SQL (16219 rows this time). So it appears the data is OK but I cannot figure out why it is not loading all the data. I do not get any errors when running the process.
Code:
string excelstring = "provider=microsoft.ace.oledb.16.0;data source=" + rptpath + filename +
";extended properties=" + "\"excel 12.0;hdr=yes;\"";
try
{
OleDbConnection oledbconnection = new OleDbConnection();
oledbconnection.ConnectionString = excelstring;
oledbconnection.Open();
DataTable dtSheet = oledbconnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
foreach (DataRow drSheet in dtSheet.Rows)
{
sheetname = drSheet["TABLE_NAME"].ToString();
}
sqlstring = "SELECT * FROM [" + sheetname + "]";
OleDbCommand oledbcommand = new OleDbCommand(sqlstring, oledbconnection);
oledbcommand.CommandTimeout = 240;
DbDataReader dr = oledbcommand.ExecuteReader();
SqlBulkCopy bulkInsert = new SqlBulkCopy(connsql);
bulkInsert.DestinationTableName = tablename;
bulkInsert.BulkCopyTimeout = 240;
bulkInsert.WriteToServer(dr);
oledbconnection.Close();
}
catch (Exception Ex)
{
ClientScript.RegisterStartupScript(GetType(), "showError", "alert('" + Ex.Message + "');", true);
errormessage = Ex.Message;
return "error";
}

How Execute SQL Query in Azure Cosmos DB with Node.js

I'm using the following document to show me how to connect and query data from Azure Cosmos DB SQL API account using Node.JS
https://learn.microsoft.com/en-us/azure/cosmos-db/create-sql-api-nodejs
There is a section in the document that is set to query the Azure Cosmos DB
// query to return all items
const querySpec = {
query: "SELECT * from c"
};
const { resources: results } = await container.items
.query(querySpec)
.fetchAll();
Can someone let me know where the results of the above query is displayed?
I'm using Visual Studio Code to build the code, but when I run it I'm not sure where the results are displayed. For example, will the results be display in Azure Cosmos DB? Within Visual Studio Code? or where?
You've probably gathered I'm a Node.JS newbie
Thanks
By default, it will show in your console where you run your code. But I did not see any output in your code, maybe you should add something like the following
if (results.length == 0) {
throw "No items found matching";
}
// Change person to your data type
const person = results[0];
console.log("The '" + person.id + "' family has lastName '" + person.lastName + "'");
console.log("The '" + person.id + "' family has " + person.children.length + " children '");

proper syntax for postgres UPDATE for more than one condition?

I have the following code to use to update and existing record in a postgres database using Node.js:
var mods = "UPDATE users SET login = '" + now + "' WHERE name = '" + String(req.body.usr) + "';";
client.query(mods, function(err, result) {
//call `done()` to release the client back to the pool
done();
if(err){
console.log(err);
}
});
I would like to provide multiple 'WHERE' conditions instead of just one...however I am having problems with syntax. For example I wish to do something like
'WHERE name = ' + String(req.body.usr) AND 'WHERE login = ' + String(req.body.password)
Any help would be appreciated, I am just having syntax issues with trying to provide more than one WHERE condition to the update query. I thank you in advance.
Don't write WHERE multiple times, just use AND to chain them. Or, you could google Postgress Where.
var mods = "UPDATE users SET login = '" + now + "' WHERE name = '" + name + "' AND login ='" + login + "' AND ... ";

Sending Push Notification to a Windows phone from Linux Server

Can we send a push notification to a windows phone from a linux server or is this bound to a windows server only?
Well i got the answer...
Make a http post to the Subscription URI
Java Code:
String toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1> Welcome To Windows Push </wp:Text1>" +
"</wp:Toast> " +
"</wp:Notification>";
byte[] notificationMessage = toastMessage.getBytes();
url = new URL(subscriptionURI); //You must have the subscription URI provided by MPNS to client side.
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("ContentLength", String.valueOf(notificationMessage.length));
connection.setRequestProperty("ContentType", "text/xml");
connection.addRequestProperty("X-WindowsPhone-Target", "toast");
connection.addRequestProperty("X-NotificationClass", "2");
connection.connect();
DataOutputStream out =
new DataOutputStream(
connection.getOutputStream());
out.write(notificationMessage, 0, notificationMessage.length);
out.close();

Resources