Sql server 2012将我的所有MDF(Sql server 2008)都更改为Sql 2012 [英] Sql server 2012 changed all of my MDF (Sql server 2008) to Sql 2012

查看:82
本文介绍了Sql server 2012将我的所有MDF(Sql server 2008)都更改为Sql 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好朋友我用mdf文件创建了一个商业项目(Sql server 2008文件)

我安装了两个版本的vs(2010,2012)。在安装vs 2012之后,我将我的mdf分离并将其添加到vs 2010中的另一个项目,但是自动(我不知道为什么!)我的mdf文件从sqlexpress更改为localdb \版本11.0并且我有非常重要的数据在它,现在我不能用SQL Express 2008这个mdf!我该怎么办?我不知道如何为sql local db 2012创建安装perquisite文件。我不知道如何轻松地使用vs 2012进行设置,但我知道如何使用vs 2010做这个,很容易安装sql在vs 2010中用设置表达,但是对于instalshield来说它是最糟糕的!,请你在这里帮助我,我被困在泥里。我不知道该怎么办。我应该删除我的窗户并重新安装它。因为我不想要sql server 2012 !!!

解决方案

我找到了答案:

首先我们创建一个exe文件安装sql server local db 2012.因为它确实很小而不是sql server 2008.

 使用系统; 
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Data;
使用 System.Drawing;
使用 System.Linq;
使用 System.Text;
使用 System.Windows.Forms;
使用 Microsoft.Win32;
使用 System.IO;
使用 System.Configuration.Install;
使用 System.Diagnostics;

命名空间 EXE
{
public partial class Form1:Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load( object sender,EventArgs e)
{
bool instalResult = ;
timer1.Enabled = true ;
string strResult = n;
strResult = fncCheckRegistry();
bool is64 = CheckCpuArcitecture();
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
string strMsix86FileName = appPath + @ \\ \\x86\SqlLocaLDB.msi;
string strMsix64FileName = appPath + @ \\ \\x64\SqlLocalDB_64.msi;
//

if (strResult!= y
{
if (is64 == false
{
instalResult = fncInstal32( strMsix86FileName);
}
}
if (strResult!= y
{
if (is64 == true
{
instalResult = fncInstal32(strMsix64FileName);
}
}
如果(instalResult)timer1.Enabled = false ;
this .Close();
}
//
public bool fncInstal32( string sMSIPath)
{
尝试
{
Console.WriteLine( 开始安装应用程序);
流程流程= 流程();
process.StartInfo.FileName = msiexec.exe;
process.StartInfo.Arguments = string .Format( / qf / i \{0} \ALLUSERS = 1 IACCEPTSQLNCLILICENSETERMS = YES,sMSIPath);
process.Start();
process.WaitForExit();
Console.WriteLine( 应用程序安装成功!);
return true ; // 如果流程成功结束,则返回True
}
catch
{
Console.WriteLine( 有安装应用程序时遇到问题!);
return false ; // 如果流程失败,则返回False
}
}
public bool CheckCpuArcitecture()
{
bool is64 = System.Environment.Is64BitOperatingSystem;
return is64;
}
//
public string fncCheckRegistry()
{
string strResult = n;

使用(RegistryKey Key = Registry.LocalMachine.OpenSubKey( @ < span class =code-string> SOFTWARE \ Microsoftoft\Microsoft SQL Server 2012 Redist \ MSSQL11E.LOCALDB\1033 \ CurrentVersion
))
if (Key!= null
{

strResult = y;
}
else
{
strResult = n;
}

return strResult;
}
bool x = false ;
private void timer1_Tick( object sender,EventArgs e)
{
if (progressBar1.Value == 100 )x = true ;
if (!x)progressBar1.Value ++;
if (progressBar1.Value == 0 )x = ;
if (x)progressBar1.Value--;
}
}
}



这会检查cpu Arcitecture以及我之前是否安装了msi。

问题从这里开始。

我在另一个安装项目中将此项目用作自定义操作中的exe。

在第二个安装项目中安装.net framework 4和windows安装程序。

但是我在设置的提交部分添加了自定义操作。

因此在第一次安装完成后(不完全没有单击完成按钮)第二次设置安装sql服务器将开始,但多么不走运我经过两天的思考我的问题它警告我有两个设置一起工作!!!

我应该怎么做朋友?你有什么建议吗?

如何在安装结束时关闭基本卸载程序并打开另一个进程?

哇我也找到了她的答案:

我找到了答案:



我们创造了一个安装程序类,我们在其中写下:

 使用系统; 
使用 System.Collections;
使用 System.Collections.Generic;
使用 System.ComponentModel;
使用 System.Configuration.Install;
使用 System.Linq;

命名空间 OpenWeb
{
[RunInstaller( true )]

public partial class Installer1:System.Configuration.Install.Installer
{
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public 覆盖 void 安装(IDictionary stateSaver)
{
base .Install(stateSaver);
}

[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public 覆盖 void 提交(IDictionary savedState)
{
.Commit(savedState);
System.Diagnostics.Process.Start(Context.Parameters [ TARGETDIR]。ToString ()+ Exe.exe);
// 非常重要!删除所有那些讨厌的临时文件。
base .Dispose();
}

[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public 覆盖 void 回滚(IDictionary savedState)
{
.Rollback(savedState);
}

[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
public 覆盖 void 卸载(IDictionary savedState)
{
.Uninstall(savedState);
}

public Installer1()
{
InitializeComponent();
}
}
}



然后我们创建我们的设置并添加我们的exe文件,我们通过添加primary来添加安装程序类输出。

现在我们通过添加主输出在提交和安装中添加自定义操作。

现在我们构建我们的设置。

Enjoy


Well friends i created a commercial project with mdf files(Sql server 2008 files)
i installed two versions of vs (2010,2012). after installing vs 2012, i detached my mdf and added it to another project in vs 2010, but automatically (i don''t know why!) my mdf file changed from sqlexpress to localdb\ version 11.0 and i had very big important data in it and now i can''t use this mdf with SQL express 2008! what should i do? i don''t know how to create install perquisite file for sql local db 2012. I don''t know how to easily make a setup with vs 2012 but i knew how to do this with vs 2010, it was easy to install sql express with setup in vs 2010, but it is worst with instalshield!, can you please help me here, i''m stucked in the mud. i don''t know what to do. should i remove my windows and install it again. cause i don''t want sql server 2012!!!

解决方案

I find my answer:
first we create an exe file that installs sql server local db 2012. because its indeed small size rather than sql server 2008.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using System.Configuration.Install;
using System.Diagnostics;
 
namespace EXE
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            bool instalResult = false;
            timer1.Enabled = true;
            string strResult = "n";
            strResult=fncCheckRegistry();
            bool is64 = CheckCpuArcitecture();
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);
            string strMsix86FileName = appPath + @"\x86\SqlLocaLDB.msi";
            string strMsix64FileName = appPath + @"\x64\SqlLocalDB_64.msi";
            //

            if (strResult != "y")
            {
                if (is64 == false)
                {
                    instalResult=fncInstal32(strMsix86FileName);
                }
            }
            if (strResult != "y")
            {
                if (is64 == true)
                {
                    instalResult = fncInstal32(strMsix64FileName);
                }
            }
            if (instalResult) timer1.Enabled = false;
            this.Close();
        }
        //
        public bool fncInstal32(string sMSIPath)
        {
            try
            {
                Console.WriteLine("Starting to install application");
                Process process = new Process();
                process.StartInfo.FileName = "msiexec.exe";
                process.StartInfo.Arguments = string.Format(" /qf /i \"{0}\" ALLUSERS=1  IACCEPTSQLNCLILICENSETERMS=YES", sMSIPath);
                process.Start();
                process.WaitForExit();
                Console.WriteLine("Application installed successfully!");
                return true; //Return True if process ended successfully
            }
            catch
            {
                Console.WriteLine("There was a problem installing the application!");
                return false;  //Return False if process ended unsuccessfully
            }
        }
        public bool CheckCpuArcitecture()
        {
            bool is64 = System.Environment.Is64BitOperatingSystem;
            return is64;
        }
        //
        public string fncCheckRegistry()
        {
            string strResult = "n";
 
            using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server 2012 Redist\MSSQL11E.LOCALDB\1033\CurrentVersion"))
                if (Key != null)
                {
 
                    strResult= "y";
                }
                else
                {
                    strResult= "n";
                }
 
            return strResult;
        }
        bool x = false;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (progressBar1.Value==100) x=true;
            if(!x) progressBar1.Value++;
            if (progressBar1.Value==0) x=false;
            if(x) progressBar1.Value--;
        }
    }
}


This checks cpu Arcitecture and if my msi is installed before.
the problem begins here.
I used this project as an exe in custom actions in a another setup project.
in the second setup project i install .net framework 4 and windows installer.
but i added custom action in the commit part of the setup.
So after the first installation finished(not completely the finish button is not clicked) the second setup that install sql server will begin, but how unlucky i am after two days of thinking on my problem it warns me about having two setup working together!!!
What should i do friends? do you have any suggestion?
How can i close the base uninstaller at the end of installation and open another process?
wow i find the answer her too:
I have find my answer:

Well we create an installer class and we write this in it:

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;

namespace OpenWeb
{
    [RunInstaller(true)]
 
    public partial class Installer1 : System.Configuration.Install.Installer
    {
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }
 
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
            System.Diagnostics.Process.Start(Context.Parameters["TARGETDIR"].ToString() + "Exe.exe");
            // Very important! Removes all those nasty temp files.
            base.Dispose();
        }
 
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);
        }
 
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
        }
 
        public Installer1()
        {
            InitializeComponent();
        }
    }
}


then we create our setup and we add our exe file and we add the installer class by adding primary output.
now we add custom action in commit and install by adding primary output there too.
now we build our setup.
Enjoy


这篇关于Sql server 2012将我的所有MDF(Sql server 2008)都更改为Sql 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆