sql server CE

  • Thread starter Thread starter Miliuccio
  • Start date Start date
M

Miliuccio

Simple application must open a database

cmd.Connection.ConnectionString = "Data Source = \My
Documents\test.sdf"
cmd.Connection.Open()

response:
Eccezione non gestita di tipo "System.NullReferenceException"

why?
 
My gues would be (without seeing the code which goes before this) that
either cmd is null, or cmd.Connection is null. Try this:-

Dim connection As New SqlConnection
connection.ConnectionString = "Data Source='\My Documents\test.sdf'"
connection.Open()
Dim cmd As SqlCommand = connection.CreateCommand()

'do something with this command

connection.Close()

Peter
 
your problem is one missing character - use the line below instead:

cmd.Connection.ConnectionString = @"Data Source = \My
Documents\test.sdf"

the \t is being interpreted as an escape sequence.
--
Darren Shaffer
..NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com
 
Back
Top