连接到SQL Server的问题

用户名

我在连接到Microsoft SQL Server 2012时遇到一些问题。这是我的代码:

private void conButton_Click(object sender, EventArgs e)
{
    string conString;

    SqlConnection appMessage;
    conString = @"Data Source=DHRANTONIUSVICT\SQLA; Initial Catalog=AppMessage; User ID=myid; Password=mypass; Server=localhost\sqlexpress";

    appMessage = new SqlConnection(conString);

    try
    {
         appMessage.Open();
         MessageBox.Show("Connection is stable. Starting up the engines...");
    }
    catch (Exception)
    {
        MessageBox.Show("Connection to HQ is unstable. Need engineers ASAP!");
    }

我无法以某种方式连接到SQL Server。我究竟做错了什么?

而且,请记住我是SQL的新手。

Santosh Singh

使用数据源或服务器。

conString = @"Data Source=DHRANTONIUSVICT\SQLA; Initial Catalog=AppMessage; User ID=myid; Password=mypass ";

请参考SqlConnection.ConnectionString文档

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章