我将连接字符串的路径插入数据库(A)。连接数据库(B)的路径使用。当我从数据库(A)中选择该路径并尝试连接数据库(B)时。这是警报信息显示
不支持关键字:' @"数据来源'。'
这是数据库(A)中的连接字符串:
@"数据源=(LocalDB)\ MSSQLLocalDB; AttachDbFilename = C:\ Users \ it_staff \ source \ repos \ MonitorProduction_Client \ MonitorProduction_Client \ App_Data \ monitorclientdb.mdf; Integrated Security = True"
connect_db.conn.Close();
connect_db.conn.Open();
SqlCommand cmd_select_connect_string = new SqlCommand("select board_connect_string from[board] where board_id='" + board_id_[0] + "'", connect_db.conn);
if (cmd_select_connect_string.ExecuteNonQuery() != 0)
{
SqlDataReader rd = cmd_select_connect_string.ExecuteReader();
while (rd.Read())
{
var board_connect_string = rd[0];
connect_db.connb=new SqlConnection(board_connect_string.ToString());
}
}
答案 0 :(得分:0)
只需从数据库中的connect_string
中删除@和两者Data Source =(LocalDB)\ MSSQLLocalDB; AttachDbFilename = C:\ Users \ it_staff \ source \ repos \ MonitorProduction_Client \ MonitorProduction_Client \ App_Data \ monitorclientdb.mdf; Integrated Security = True