Android Question Help with SQL Server ExecQuery

sapril

Member
Licensed User
Hello, I am trying to read data from my SQL Server

Library
MSSQL.jar

Code:

Dim Connection As MSSQL
Dim sql As SQL

Connection.setDatabase("192.168.1.5","persons","sa","")
Dim Rs As ResultSet=sql.ExecQuery("Select Address from persons where name='" & txtUser.Text & "'")
For i = 0 To Rs.RowCount -1
Rs.Position=i
txtPassword.Text=Rs.GetString("Address")
Next

I see the following error:

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 116 (Main)
java.lang.RuntimeException: Object should first be initialized.
at anywheresoftware.b4a.sql.SQL.checkNull(SQL.java:55)
at anywheresoftware.b4a.sql.SQL.ExecQuery(SQL.java:210)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)


Please help...
 

sapril

Member
Licensed User
Ok, thank you ..

Is there an example as asked above? .. focus on getstring with sqlserver database .. sorry I'm still a beginner ..
 
Upvote 0

sapril

Member
Licensed User
Please use [code]code here...[/code] tags when posting code.

You should use JdbcSQL if you want to directly connect to the database. Make sure to use the async SQL methods in that case.

Ok, thank you ..

Is there an example as asked above? .. focus on getstring with sqlserver database .. sorry I'm still a beginner ..
 
Upvote 0
Top