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.
- SqlConnection con = new SqlConnection(str1);
- //SqlConnection con1 = new SqlConnection(constr);
- DateTime DATEFROM = System.DateTime.Today;
- string DFrom = Convert.ToString(DATEFROM.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
- 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 + "'";
- SqlDataAdapter adpt = new SqlDataAdapter(com, con);
- DataTable dt = new DataTable();
- adpt.Fill(dt);
- 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

Ramachandran MRank #2,660 · 522 reputationPosted Feb 12, 2020, 6:31 PM EST
Sudeer Kumar SankepellyRank #4,768 · 326 reputationPosted Feb 12, 2020, 7:09 PM EST