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
 

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

Back
Top