MVC4是我的SQL Server 2014连接字符串是否正确

时间:2016-03-01 19:02:02

标签: sql-server asp.net-mvc-4 database-connection connection-string

我使用Visual Studio 2012 for Web和我编写MVC应用程序。默认情况下它使用localDB但我想在SQL Server上使用它。我已经安装了SQL Server 2014,我的服务器名是C0208 \ SQLEXPRESS。

C0208是我的电脑名称

命名实例:SQLEXPRESS

InstanceID:SQLEXPRESS

这是我对localdb的连接字符串

<add name="IssueContext" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=RecreationalServicesTicketingSystem;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\RecreationalServicesTicketingSystem.mdf" providerName="System.Data.SqlClient" />

我尝试使用此连接字符串,但我不知道它是否正确

<add name="IssueContext" providerName="System.Data.SqlClient" connectionString="Data Source=C0208\SQLEXPRESS;User Id=C0208;Initial Catalog=DatabaseName;Integrated Security=True;MultipleActiveResultSets=True" />

1 个答案:

答案 0 :(得分:0)

这看起来更像是一个Entity Framework问题,而不是SQL连接字符串。只需检查您是否在任何地方更新了连接字符串。 (的的app.config )。 要启用数据迁移,您必须在程序包管理器控制台中运行以下命令。

DECLARE
   px_return    XMLTYPE
      := XMLTYPE (
            '<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Header xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
        <h:AxisValues xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:h="urn:/microsoft/multichannelframework/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:/microsoft/multichannelframework/">
            <User xmlns="">FSCD</User>
            <Solution xmlns="">Multicare</Solution>
            <ApplicationalUser xmlns=""/>
            <ApplicationalUserSystem xmlns=""/>
            <SystemUser xmlns=""/>
            <SystemUserSystem xmlns=""/>
            <Proxy xmlns="">0</Proxy>
        </h:AxisValues>
    </SOAP:Header>
    <SOAP:Body xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
        <ns1:maintainMandateResponse xmlns:ns1="urn:enterprise.com/ws/SAP/Finantial/MaintainMandate/V1">
            <return>
                <messageType>E</messageType>
            </return>
        </ns1:maintainMandateResponse>
    </SOAP:Body>
</soapenv:Envelope>');

   lv_msgType   VARCHAR2 (20);
BEGIN
   SELECT Return.msgType
     INTO lv_msgType
     FROM XMLTABLE (
             xmlnamespaces (
                DEFAULT 'enterprise.com/ws/SAP/Finantial/MaintainMandate/V1',
                'http://schemas.xmlsoap.org/soap/envelope/' AS "soapenv",
                'http://schemas.xmlsoap.org/soap/envelope/' AS "SOAP",
                'enterprise.com/ws/SAP/Finantial/MaintainMandate/V1' AS "ns1"),
             '//soapenv:Envelope/SOAP:Body/ns1:maintainMandateResponse'
             PASSING px_return
             COLUMNS msgType VARCHAR2 (1) PATH 'messageType') Return;


   DBMS_OUTPUT.put_line ('Message type: ' || lv_msgType);
END;

如果它给出错误,请先尝试以下命令

return

有关详细信息,请查看this link