0

Need example how to create new local database and a connection string, if possible with a using statement.

There should be 1 table and the data that I want to put in there are unique words length 2-50 lowercase characters, and thy can contain "a-zõäöüšž", ordered by ascending.

There are 2 actions I want to do with that:

  1. Put HashSet of string called words in
  2. Get HashSet of string called words that are specific length

Optionally, I could use an example how to reduce amount of answers given by Get, by telling what letter x must be or what it can not be in a specific location within length of word.

Edit Found my answer by Google.

Margus
  • 19,694
  • 14
  • 55
  • 103
  • I am not sure what are asking for, but these tutorials might help you: http://www.asp.net/web-forms/data. These are for asp, but they give a good idea of how to work with DB's in general. – Artium Sep 20 '10 at 10:27

3 Answers3

0

you can do all using code, but I would recommend that you ship at least one empty SQL 2008 Express database (mdf file) in your program.

and use the normal Connection String

I did stop shipping SQL Express and only use SQLite now. It's fast and fantastic to use as settings keeper and much more, and I stop having problems in installing this and that on client side to support MS SQL stuff.

I use this on both windows and web apps.

balexandre
  • 73,608
  • 45
  • 233
  • 342
  • Really don't like this advice (to ship an empty MDF) - but I'm not sure I'm qualified to downvote (in terms of knowing best as opposed to anything else) – Murph Sep 20 '10 at 10:49
  • How can you create a Database then?? what type? Oracle? MS? SQLite would be the best option, but u need to ship your product with the correct dll's! Please rephrase your question! – balexandre Sep 20 '10 at 11:34
  • Erm, providing a database engine is entirely different to shipping a blank database. Yes, in order to use any database you have to provide the appropriate runtime. If you want to avoid an install then I won't dispute that SQLite is an excellent solution and MS SQL CE can also be shipped as .DLLs as part of an application. But I can't see how shipping a *data file* will address the problem. – Murph Sep 20 '10 at 12:06
0

I am not sure I understand your question but you can use SQL Server Compact Edition (SQL ServerCE) as a local database.
You can deal with it as if you are using SQL Server but with the namespace SqlServerCe instead of SqlClient.

sh_kamalh
  • 3,853
  • 4
  • 38
  • 50
0

In terms of creating databases and schemas from code (C# and MS SQL Server), I have sample code here:

How to create "embedded" SQL 2008 database file if it doesn't exist?

Community
  • 1
  • 1
Murph
  • 9,985
  • 2
  • 26
  • 41