Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Afaf_A_
Beginner
79 Views

Intel XDK DataBase

Hello, 

I’m a beginner in INTEL XDK, the first problem that I face is what is the easiest way to connect a database to my INTEL XDK ?

I’m using SQL server 2012 management studio, can I connect it with XDK ? or there is other way to create a database and connect it with Intel XDK.

Please post an English video if a vailable.

Thank you.

Tags (2)
0 Kudos
2 Replies
PaulF_IntelCorp
Employee
79 Views

Afaf -- the XDK creates standard Cordova (aka PhoneGap) apps, so your best bet is to search the Internet for something like "database solutions for cordova phonegap apps" and try some of those solutions. Solutions that work for Cordova and PhoneGap also work for the XDK.

Rodrigo_M_1
New Contributor II
79 Views

Afaf A., if your app is for mobile, you may use a Webservice as interface !

You can use ajax to connect to a webservice!

Follow some Code as example:

function callWebService(pUserAccount, pPassword, callback){
	$.ajax('http://YourWebServiceAddress/Service.asmx/MyWebservice', {
		contentType: 'text/xml; charset=utf-8',    
		dataType: 'xml',
		crossDomain: true,    
		data: {
			pUserAccount : pUserAccount, 
			pPassword : pPassword                    
		},
		success: function(data) {		
			var vMyArrayList = [];                    

			$(data).find("dsMyWSDataset").each(function () {
				//Let's build our array object and put all data from WS on it!
				vMyArrayList.push({MyItemOne: $(this).find("MyItemOne").text(), 
									MyItemTwoo: $(this).find("MyItemTwoo").text()});
			});
			
			//You may call another function in here to pass your result of your Webservice:
			fn_MyOtherFunction(vMyArrayList, function(res){
				if(res){
					//Some other code
					callback(true);
				}
			});
		},
		error: function (data) {
			alert('Error: ' + $(data).text);		
			callback(false);
		}
	});
}

//Function to Extract your Array Obj.
function fn_MyOtherFunction(pMyArrayList, callback){
	var j = pMyArrayList.length;                 
	for (var i = 0; i < j; i++) {
		 var vItem = pServiceLocationsList;
		 console.log(vItem.MyItemOne);
		 console.log(vItem.MyItemTwoo);
		 //Do something else...
	}
	callback(true);
}

//Call your WS Function:
callWebService('MyUserAccount', '123456',function(res){
	//Do Something After this function Callback...
});

 

And a WS Template with Vb.Net where I call a Stored Procedure on SQL:

<WebMethod()> _
Public Function MyWebservice(ByVal pUserAccount As String, ByVal pPassword As String) As DataSet
	Dim vClassResult As New classSecurity
	vClassResult.ClassSQLConn()

	Dim SqlConn As New SqlConnection(vClassResult.ClassSQLConn())
	Dim MyDataAdapter As SqlDataAdapter
	Dim MyDataset As DataSet = Nothing

	MyDataAdapter = New SqlDataAdapter("EXEC dbo.sprAuthenticateUser '" & pUserAccount & "','" & pPassword & "'", SqlConn)

	MyDataset = New DataSet()
	MyDataAdapter.Fill(MyDataset, "dsMyWSDataset")

	SqlConn.Close()

	Return MyDataset
End Function
Reply