shreyas adikumar

shreyas adikumar

  • NA
  • 85
  • 10.1k

how to combine two different database server

Feb 12 2020 11:15 PM
hi i tried to join the two different databse sever into single query in asp.net.I am geeting can anyone help me regarding this it will be a great help.
  1. SqlConnection con = new SqlConnection(str1);  
  2. //SqlConnection con1 = new SqlConnection(constr);  
  3. DateTime DATEFROM = System.DateTime.Today;  
  4. string DFrom = Convert.ToString(DATEFROM.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));  
  5. string com = " select count (*) as counts FROM [PVQC2].[dbo].[Man_Allocation] inner JOIN [Man_Allocation1].[dbo].[Mx_VEW_APIDailyAttendance] ON [Man_Allocation].[Emp_Id] = [Mx_VEW_APIDailyAttendance]. UserID where [Mx_VEW_APIDailyAttendance].UserID='" + lblUserId.Text + "' and [Mx_VEW_APIDailyAttendance].ProcessDate='" + DFrom + "'";  
  6. SqlDataAdapter adpt = new SqlDataAdapter(com, con);  
  7. DataTable dt = new DataTable();  
  8. adpt.Fill(dt);  
  9. lblp2.Text = dt.Rows[0]["COUNTS"].ToString();  
Error occured is
 
Invalid object name 'PVQC2.dbo.Man_Allocation'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'PVQC2.dbo.Man_Allocation'.
Source Error:
Line 87: Line 88: DataTable dt = new DataTable(); Line 89: adpt.Fill(dt); Line 90: lblp2.Text = dt.Rows[0]["COUNTS"].ToString(); Line 91:
Source File: d:\PreethamFiles\PVQCrework\PVQC_WEB\UI\Master\HCM\MasterEmployee.aspx.cs Line: 89

Answers (2)