Connection à SQL Server 2005 d'une appli CE
Bonjour à tous,
je tente d'accéder à une instance SQL Server 2005 (Windows XP) à partir d'une application VB.NET CE (Compact Framework 3.5 sous Windows CE). Tout semble bien fonctionner (connection, query,etc) mais les valeurs retournées dans ma datatable sont tous vides! Par contre je vois le nom des colonnes retournées sans problème.
J'ai entendu dire qu'il faut activer une parametre sur le serveur 2005 pour permettre la communication de bien se faire...mais je ne trouve pas.
Voici mon code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim mconSQL As New System.Data.SqlClient.SqlConnection
Dim SQLDBDataReader As System.Data.SqlClient.SqlDataReader
Dim FieldValues(0) As Object
Dim SQLDataTable As New System.Data.DataTable
Dim strConnect As String
Dim intCount As Integer
strConnect = "Data Source=" & "ORD-DB" & ";Initial Catalog=" & "TestDB" & ";" _
& "User ID=" & "admin" & ";" _
& "Pwd=" & "admin" & ";Connect Timeout=200;"
mconSQL.ConnectionString = strConnect
mconSQL.Open()
Dim cmdSQL As New System.Data.SqlClient.SqlCommand
cmdSQL.CommandText = "StoredProcedureTest"
cmdSQL.CommandType = Data.CommandType.StoredProcedure
cmdSQL.CommandTimeout = 1800
cmdSQL.Connection = mconSQL
If cmdSQL.Connection.State <> System.Data.ConnectionState.Open Then
cmdSQL.Connection.Open()
End If
SQLDBDataReader = cmdSQL.ExecuteReader()
For intCount = 0 To SQLDBDataReader.FieldCount - 1
SQLDataTable.Columns.Add(SQLDBDataReader.GetName(intCount), SQLDBDataReader.GetFieldType(intCount))
Next
While (SQLDBDataReader.Read)
SQLDBDataReader.GetValues(FieldValues)
SQLDataTable.Rows.Add(FieldValues)
End While
Dim str As String
If Not SQLDataTable Is Nothing Then
If SQLDataTable.Rows.Count > 0 Then
For intCount = 0 To 5
str = (SQLDataTable.Rows(intCount).Item("Name")).ToString '<-Retourne "" (vide) a chaque fois!
Next
End If
End If
SQLDBDataReader.Close()
SQLDBDataReader = Nothing
cmdSQL.Connection.Close()
Exit Sub
Catch ex As Exception
MsgBox("error")
End Try
End Sub |
Je ne suis pas certain si je dois poster ceci ici ou dans un forum vb.net quelconque
Merci à l'avance