Problem with sqlclient.open
I have an application i am developing on a psc 4420 that i want to connect to a sql server on my pc. i have the code:
Dim con As SqlClient.SqlConnection = New SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand = New SqlClient.SqlCommand
Dim da As New SqlClient.SqlDataAdapter(cmd)
Dim ds As New DataSet
Dim dr As DataRow
con.ConnectionString = "Persist Security Info=False;Integrated Security=false;database=SMSM2MDATA;server=192.168.123.50;User ID=sa;Password="
con.Open()
Try
cmd.CommandText = "Select distinct fdept from employee"
cmd.CommandType = CommandType.Text
cmd.Connection = con
da.Fill(ds, "DeptList")
For Each dr In ds.Tables("DeptList").Rows
ComboBox1.Items.Add(dr("fdept").ToString)
Next
ComboBox1.SelectedIndex = 0
Catch exp As Exception
MessageBox.Show(exp.Message)
Finally
If con.State <> ConnectionState.Closed Then
con.Close()
End If
End Try
when testing the code in the debugger on the device, i get a "An unhandled exception of type 'System.MissingMethodException' occurred in System.Data.SqlClient.dll"
i have no idea what is causeing this error. i can run the same code from a desktop app and i get no errors.
any help would be much appreciated.
thanks
dougg
Re: Problem with sqlclient.open
on what line of code does it throw the exception??????
Re: Problem with sqlclient.open
here is a sample of my code
VB Code:
Dim l_cn As SqlConnection
Dim l_connString As String
l_connString = "user id=sa;password=;database=test;Server=192.168.10.180"
l_cn = New SqlConnection(l_connString)
l_cn.Open()
Dim l_sql As String = "SELECT * FROM tbl_Supplier"
Try
Dim l_cmd As SqlCommand = l_cn.CreateCommand
l_cmd.CommandText = l_sql
l_cmd.CommandType = CommandType.Text
'MsgBox(l_cmd.ExecuteScalar)
Dim l_dr As SqlDataReader
l_dr = l_cmd.ExecuteReader
While l_dr.Read
ListBox1.Items.Add(l_dr.GetValue(1))
End While
Catch ex As SqlException
Dim l_sqlerr As SqlError
For Each l_sqlerr In ex.Errors
MsgBox(l_sqlerr.Message)
Next
End Try
Re: Problem with sqlclient.open
it errors on the .open line
i know that the connection string is valid. the thing i have found though is that it will work when connecting to sql server running on a network server but not to sql server running on a personal computer. i am still looking into possible differences in the installs of these but think they are the same. any ideas?
Re: Problem with sqlclient.open
i can connect to msde running on my pc and also to our sql server without any issues