|
-
Sep 12th, 2005, 08:24 AM
#1
Thread Starter
Junior Member
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
-
Sep 13th, 2005, 03:13 AM
#2
Fanatic Member
Re: Problem with sqlclient.open
on what line of code does it throw the exception??????
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Sep 13th, 2005, 03:18 AM
#3
Fanatic Member
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
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Sep 13th, 2005, 07:41 AM
#4
Thread Starter
Junior Member
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?
-
Sep 13th, 2005, 07:50 AM
#5
Fanatic Member
Re: Problem with sqlclient.open
i can connect to msde running on my pc and also to our sql server without any issues
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|