Hi all,
I'm trying to build a small mobile app that populates a combo box from a sql server located on a server.
The error returned is a 'SQL Exception' and the code bombs out on the connection.open() statement.
The code works when run on a windows application but it fails to connect on a mobile application.
Can anybody spot where i have gone wrong as i have been staring at this all day!!
Many Thanks
I'm trying to build a small mobile app that populates a combo box from a sql server located on a server.
The error returned is a 'SQL Exception' and the code bombs out on the connection.open() statement.
Code:
Imports System
Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient.SqlConnection
Imports System.Data.SqlClient.SqlCommand
Imports System.Data.SqlClient.SqlException
Imports System.Drawing
Imports System.Data.SqlClient.SqlDataReader
Try
Dim strSelectCustomers As String = "SELECT CustId, (CustSName + ' ' + CustFName) as [CustName] FROM TblCustTable"
Dim strConnString As String = "data source=192.168.1.103;database=Project;integrated security=SSPI;user ID=IUSR_JAMES;Password=password"
' Using the connection object
Dim connProject As New SqlClient.SqlConnection
connProject.ConnectionString = strConnString
Dim cmdCustomers As New SqlCommand(strSelectCustomers, connProject)
Dim drCustomers As SqlDataReader
connProject.Open()
drCustomers = cmdCustomers.ExecuteReader()
Dim StrState As String
StrState = connProject.State.ToString()
TextBox1.Text = StrState.ToString()
MsgBox("connected and datareader populated")
connProject.Close()
Catch excNull As Exception
MsgBox("1: " & excNull.Message)
'Console.WriteLine(excNull.InnerException)
StatusBar1.Text = "1: " & excNull.GetBaseException.Message
Catch excPaul As NullReferenceException
MsgBox("2: " & excPaul.Message.GetHashCode)
'Console.WriteLine(excNull.InnerException)
StatusBar1.Text = excPaul.Message.GetHashCode
End Try
The code works when run on a windows application but it fails to connect on a mobile application.
Can anybody spot where i have gone wrong as i have been staring at this all day!!
Many Thanks