//############### Model 2 #############################################################
/**
*This set of code is using the MS SQL library kindly suggested by keirS on this topic page:
*
https://www.b4x.com/android/forum/threads/connect-directly-to-remote-ms-sql-db.67927/
*
*It works perfectly, with no crashes or warnings whatsoever (not even an exception),
*except that there is no data returned in the List variable "L" as one can see from the watch window
*pictured below.
*/
//------------------------------------------------------------
//Manifest Editor Entry
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
AddPermission("android.permission.INTERNET")
AddPermission("android.permission.ACCESS_NETWORK_STATE")
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
//------------------------------------------------------------
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
Dim db As MSSQL
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim L As List
' db = setDatabase("Server IPNUMBER (not name)","databasename","username","password")
db.setDatabase("Remote SQL Server URL:1433/","TableName","Login","Password")//Redacted for security
'
Try
'select query
//I've tried with "TableName", "[dbo].TableName", and "[DB_Name].[dbo].[TableName]"
//No difference
L = db.Query("select * from TableName") '--> return rows as a LIST
//=========================================================
L = db.TableList '--> return table list in database
//=========================================================
' or update query (True: If need transactional query)
' db.ExecuteNonQuery("update tablename set fieldname = 'forexample' where key=1",True)
Catch
Msgbox(LastException.Message,"Error Occured")
End Try
End Sub
//############### End Model 2 #########################################################
I have this working PERFECTLY in IntelliJ using the AsynchTask methodology, but I'm sick to DEATH of their "Cat's ball of yarn" IDE.
Erel, you wrote to me once at (
https://www.b4x.com/android/forum/t...ct-to-any-remote-db.31540/page-14#post-297277)
(Caps and bolding are mine for emphasis)
"
ANYTHING THAT YOU CAN DO IN JAVA CAN BE DONE WITH B4A.If the jdbc driver is supported by Android then you can use it in B4A (with a wrapper).
In most cases it is not recommended to connect directly to the database from the mobile app for various reasons including security.
Use the forum search to find relevant libraries:
https://www.b4x.com/android/forum/pages/results/?query=mssql&page=1&prefix=1"
Now I know all of the security caveats, but
a). I don't control the Amazon AWS server, and can't put apps or servelets on it, and
b) I don't give a rat's ass about the credentials being in plain text.
If someone else steals or finds the tablets or phones I deploy this to, changing the credentials on the server is a quick and sinplefix,
and there will be bigger problems than a competitor having a useless login.
This will be used only for private use, and will never be in the app store.
Isn't there a solution that works in B4A without fighting with the Android mess to get there? Isn't that the B4A raison d`etre?
Isn't that what you meant by "Anything that you can do in Java can be done with B4A."
You have always been helpful, responsive, and probably the smartest person I've ever interacted with. (I was a reactor operator in the US Navy, A programmer for Lucent Technologies for 4 years, and worked for 4 years as an architect\developer for a garage startup that is now a multi-state, multi-million dollar concern with huge customers in a huge customer base 10 years later. I say that all not to toot my horn, but so you understand I'm qualified to say it, and not saying "probably the smartest person... " lightly.)
B4A is great. I have created several professional apps for Android using it and SQLite, but this JDBC connectivity through Android is the biggest PITA I've encountered in, literally, years.
I get the feeling that you're holding back, but I don't understand why.
Please help me figure this out so I don't have to use the Android mess.