As already pointed out: when both databases share the same server instance, one connectionstring will do, you simply use the full qualified name of the table. I would recommend putting the two statements in a transaction block though, either both succeed or none. Something like this:
using (IDbConnection connection = new SqlConnection(ConnectionString))
{
connection.Open();
var transaction = connection.BeginTransaction();
try
{
string sSql1 = "INSERT INTO [A].dbo.tbl_std (userid) VALUES ( @USERID ) "
string sSql2 = "INSERT INTO [B].dbo.tbl_cust (userid) VALUES ( @USERID ) "
var command1 = new SqlCommand(sSql1, connection);
command1.Parameters.Add(new SqlParameter("@USERID", 101));
var command2 = new SqlCommand(sSql2, connection);
command2.Parameters.Add(new SqlParameter("@USERID", 101));
int iRecordsAffected1 = command1.ExecuteNonQuery();
int iRecordsAffected2 = command2.ExecuteNonQuery();
transaction.Commit();
}
catch (Exception ex)
{
Logger.Error(ex);
transaction.Rollback();
}
}