I can try to publishing my application but I have 2 problems: my first is I can't create database with this code
if not exists(select * from sys.databases where name = 'deneme1db')
begin
CREATE DATABASE deneme1db ON PRIMARY
(NAME = deneme1db,FILENAME = 'C:\\deneme1db.mdf',
SIZE = 5MB, MAXSIZE = 10MB, FILEGROWTH = 10%)
LOG ON (NAME = deneme1db_log, FILENAME = 'C:\\deneme1db_log.ldf',
SIZE = 1MB, MAXSIZE = 10MB, FILEGROWTH = 10%)
end
I get this error
Msg 5123, Level 16, State 1, Line 1
CREATE FILE encountered operating system error 5(Access Denied.) while attempting to open or create the physical file 'C:\deneme1db.mdf'.Msg 1802, Level 16, State 4, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
My second error on registry. I try the run this
string[] sql = (string[])Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Microsoft")
.OpenSubKey("Microsoft SQL Server").GetValue("InstalledInstances");
var ar = (from s in sql where s.Contains("SQLEXPRESS") select s ).FirstOrDefault();
if(ar==null)
{
label1.Text = "no value";
}
else
{
label1.Text = "find value";
}
string[] sql
every time returns null but if I change the prefer-32 bit from build properties code run but can't change on setup