npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cocodintech/cordova-plugin-sqlserver

v1.0.1

Published

Access to SQL Server database directly without any service

Downloads

5

Readme

cordova-plugin-sqlserver

Cordova Plugin to connect to SQL Server without services

Sometimes we need to access to databse directly without any server as middleware. The purpose of this plugin is to avoid using services to access data directly.

It can be used on Cordova, PhoneGap and Ionic.

This version is compatible with iOS and Android platforms (IOS not tested yet in this fork!!!)

Instalation

cordova plugins add  @cocodintech/cordova-plugin-sqlserver

You can download the plugin and add it to your project as a local plugin

cordova plugin add /path/to/folder

It is also possible to install via repo url directly

cordova plugin add https://github.com/cocodinTech/cordova-plugin-sqlserver.git

How to use it

After add the plugin just intialize it with database parameters server, instance (could be empty "" ), username, password, database name. For example:

SqlServer.init("192.168.0.120:1433", "SQLEXPRESS", "sa", "01234567", "dinademo", function(event) {
  alert(JSON.stringify(event));
}, function(error) {
  alert(JSON.stringify(error));
});

On success it will return "Plugin initialized"

After that you can test your database connection with

SqlServer.testConnection(function(event) {
  alert(JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});				

On succes in this case it will return "Connection succeeded"

Query execution

At this moment there is two general purpose methods:

  • executeQuery : Just execute the query on server side and return a JSON formatted array
  • execute: Execute an INSERT, UPDATE, DELETE and return {rowsAffected: number} when succed or the database error on fail

executeQuery method

Once the plugin is initialized you can execute a query on SQL Server by doing

SqlServer.executeQuery("select * from test_table where test_code=1", function(event) { 
  alert(JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});				

You can call a Store Procedure also

SqlServer.executeQuery("exec i_store_test '500048', '1', 'MMMM'", function(event) {
  alert(JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});

execute method

In order to execute an INSERT, DELETE or UPDATE just use somethig like

SqlServer.execute("update table_test set field_test=22 where key_test=500048", function(event) {
  alert("Update complete : " + JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});

Important

If you need subsequent calls to the database in the ios version you will not be able to do the following

SqlServer.executeQuery("select * from test_table where test_code=1", function(event) {
  alert(JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});				

SqlServer.executeQuery("exec i_store_test '500048', '1', 'MMMM'", function(event) {
  alert(JSON.stringify(event));
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});

You must do this in the following way to avoid EXCE_BAD_ACCESS error on ios platforms

SqlServer.executeQuery("select * from test_table where test_code=1", function(event) {
    
  // On first call completed
  SqlServer.executeQuery("exec i_store_test '500048', '1', 'MMMM'", function(event) {
    alert(JSON.stringify(event));
  }, function(error) {
    alert("Error : " + JSON.stringify(error));
  });
  
}, function(error) {
  alert("Error : " + JSON.stringify(error));
});				

Credits

  • @SergioDosSantos for the original cordova-plugin-sqlserver from which this plugin is forked.