Results 1 to 5 of 5

Thread: Problem with sqlclient.open

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    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

  2. #2
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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

  3. #3
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Problem with sqlclient.open

    here is a sample of my code

    VB Code:
    1. Dim l_cn As SqlConnection
    2. Dim l_connString As String
    3.  l_connString = "user id=sa;password=;database=test;Server=192.168.10.180"
    4. l_cn = New SqlConnection(l_connString)
    5. l_cn.Open()
    6.  
    7.  Dim l_sql As String = "SELECT * FROM tbl_Supplier"
    8.         Try
    9.             Dim l_cmd As SqlCommand = l_cn.CreateCommand
    10.             l_cmd.CommandText = l_sql
    11.             l_cmd.CommandType = CommandType.Text
    12.  
    13.             'MsgBox(l_cmd.ExecuteScalar)
    14.  
    15.             Dim l_dr As SqlDataReader
    16.             l_dr = l_cmd.ExecuteReader
    17.  
    18.             While l_dr.Read
    19.                 ListBox1.Items.Add(l_dr.GetValue(1))
    20.             End While
    21.  
    22.         Catch ex As SqlException
    23.             Dim l_sqlerr As SqlError
    24.             For Each l_sqlerr In ex.Errors
    25.                 MsgBox(l_sqlerr.Message)
    26.             Next
    27.         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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    16

    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?

  5. #5
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    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
  •  



Click Here to Expand Forum to Full Width