sql Connection Error

E

Ertugrul Ozurun

Hi,

I want to write a VB.NET application which will run on a pocket device
runnin g Windows CE 4.1 (Build 988) and make connection with desktop
SQL Server 2000. But both emulator (Windows CE 4.1) and device
generates following error:

An unhandled exception of type 'System.PlatformNotSupportedException'
occurred in System.Data.SqlClient.dll
Additional information: PlatformNotSupportedException

I have also tried to test a sample application in Microsoft KB 308049
(How to call a parameterized stored procedure by Using ADO.NEt...) but
application generated error while trying to open sql server
connection. I have tried various connection strings like

"Data Source = Server IP; Initial catalog=pubs; Integrated
Security=SSPI; User Id=Domain\administrator; Pwd=adminpass"

"Data Source = Server IP; Initial catalog=pubs; Persists Security
Info=True; User Id=sa; Pwd=sapass"

Code in KB 308049 is as follows:

Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
MyBase.Dispose(disposing)
End Sub

'NOTE: The following procedure is required by the Windows Form
Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(40, 24)
Me.Button1.Size = New System.Drawing.Size(96, 24)
Me.Button1.Text = "Button1"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 72)
Me.Label1.Size = New System.Drawing.Size(160, 64)
Me.Label1.Text = "Label1"
'
'Form1
'
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button1)
Me.Text = "Form1"

End Sub

Public Shared Sub Main()
Application.Run(New Form1)
End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim PubsConn As SqlClient.SqlConnection = New
SqlClient.SqlConnection("Integrated Security=SSPI;Data
Source=192.168.0.4;User ID=BISODNT\administrator;Pwd=soft;Initial
Catalog=pubs;")
Dim testCmd As SqlCommand = New SqlCommand("TestProc",
PubsConn)
testCmd.CommandType = CommandType.StoredProcedure
Dim retvalue As SqlParameter =
testCmd.Parameters.Add("RetValue", SqlDbType.Int)
retvalue.Direction = ParameterDirection.ReturnValue
Dim auIDIN As SqlParameter =
testCmd.Parameters.Add("@au_idIN", SqlDbType.VarChar, 11)
auIDIN.Direction = ParameterDirection.Input
Dim NumTitles As SqlParameter =
testCmd.Parameters.Add("@numtitlesout", SqlDbType.Int)
NumTitles.Direction = ParameterDirection.Output

auIDIN.Value = "213-46-8915"
PubsConn.Open()

Dim myReader As SqlDataReader = testCmd.ExecuteReader()
Console.WriteLine("Book Titles for this Author:")
Do While myReader.Read
Console.WriteLine("{0}", myReader.GetString(2))
Loop
myReader.Close()

Label1.Text = "Number of records:" & NumTitles.Value
End Sub
End Class
 
E

Ertugrul Ozurun

Hello again,

I have found the reason of my problem. My desktop SQL 2000 has a
different collation than Latin1_General_CI_AS, so collation
compatibility generated this error. When I have changed the collation
of database and its tables to Latin1_General_CI_AS, my application has
worked.

But, my database and its tables must be
SQL_Latin1_General_CP1254_CI_AS (Turkish character set). Also this
database replicates with two other databases. So, I Know the reason
but I dont know how to overcome this problem.

Awaiting your comments

Ertugrul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top