Solved

invalid object name 'dbo.pSupervisorCheck_EOL'

Posted on 2011-02-14
6
578 Views
Last Modified: 2012-05-11
Working on a program "Supervisor" written in MFC on MS Visual c++ 2005 , the program is used to log in with supervisor user name and password, then adjust the "SoftVer"data in SQL SERVER 2005.
The following code is my ADO database connection part. and attached the SQL server image and error msg image.
_ConnectionPtr pConnection = NULL;
	_CommandPtr cmmd = NULL;
	_ParameterPtr param = NULL;
	_RecordsetPtr pRs = NULL;

	HRESULT  hr= S_OK;
	_bstr_t  strCnn(_T("Provider=sqloledb; Network Library=DBMSSOCN; Data Source=555.55.555.55,1433; Initial Catalog=Central_DB; User Id='"+strRegName+"'; Password='"+strPWD+"';")); 
	
	try
	{
		TESTHR(pConnection.CreateInstance(__uuidof(Connection)));   
		hr = pConnection->Open(strCnn,"","",NULL);   
		(cmmd.CreateInstance(__uuidof(Command)));	
		

		param = cmmd->CreateParameter(_T("")/*UserName*/,adVarChar,adParamInput,strUserName.GetLength()+1,_variant_t(strUserName));   
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*LoginPWD*/,adVarChar,adParamInput,strLoginPWD.GetLength()+1,_variant_t(strLoginPWD));   
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*FactoryID*/,adVarChar, adParamInput,strFactoryID.GetLength()+1,_variant_t(strFactoryID));     
		cmmd->Parameters->Append(param);   
		param = cmmd->CreateParameter(_T("")/*LineID*/,adVarChar,adParamInput,strLineID.GetLength()+1,_variant_t(strLineID));   
		cmmd->Parameters->Append(param);
		//Return para
		param = cmmd->CreateParameter(_T("Result")/*Result*/,adVarChar, adParamOutput,50,_variant_t(strResult)); 
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Year")/*Year*/,adVarChar,adParamOutput,50,_variant_t(strYear));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Model")/*Model*/,adVarChar,adParamOutput,50,_variant_t(strUBMModel));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("Material")/*Material*/,adVarChar,adParamOutput,50,_variant_t(strMaterial));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("SoftwareVer")/*SoftVer*/,adVarChar,adParamOutput,50,_variant_t(strSoftVer));   
		cmmd->Parameters->Append(param);
		param = cmmd->CreateParameter(_T("CalibrationVer")/*CalVer*/,adVarChar,adParamOutput,50,_variant_t(strCalVer));   
		cmmd->Parameters->Append(param);		
		
		cmmd->CommandText=_bstr_t(_T("pLoginCheck_EOL"));   
		cmmd->ActiveConnection = pConnection;  
		cmmd->CommandType=adCmdStoredProc;     
	     
		cmmd->Execute(NULL,   NULL,   adCmdStoredProc);  

		strResult=cmmd->Parameters->GetItem(_T("Result"))->GetValue();     	
		
		
		if (strResult==_T("Fail"))
		{
			cmmd.Detach(); 
			GetDlgItem(IDC_Status)->SetWindowTextA(_T("Error:Login Fail!"));
			m_lbStatus.SetTextColor(RGB(255,0,0));
			return;
		}
		else
		{
			GetDlgItem(IDC_Status)->SetWindowTextA(_T("Login Success!"));
			strYear=cmmd->Parameters->GetItem(_T("Year"))->GetValue();
			strUBMModel=cmmd->Parameters->GetItem(_T("Model"))->GetValue();
			strMaterial=cmmd->Parameters->GetItem(_T("Material"))->GetValue();
			strSoftVer=cmmd->Parameters->GetItem(_T("SoftwareVer"))->GetValue();
			strCalVer=cmmd->Parameters->GetItem(_T("CalibrationVer"))->GetValue();
			cmmd.Detach();  

		}

Open in new window


sql procedure image error message
0
Comment
Question by:snowycanada
  • 3
  • 3
6 Comments
 
LVL 7

Expert Comment

by:lundnak
ID: 34892175
Does your userid have execute privileges on the stored procedure?
0
 

Author Comment

by:snowycanada
ID: 34894442
In database user "Steven"->propertiies->securable, It's blank.
I tried to add the procedure in the securable and give all the permission, but the problem is still.
0
 
LVL 7

Expert Comment

by:lundnak
ID: 34896694
I'm curious to find out if you are actually connecting to the SQL Server instance as that user id.
Would you be able to put a wait or sleep call in your code (wait minute or so) right before you execute the stored procedure?  Then open SQL Server management studio and run "exec sp_who2" in a SQL window in order to see what sessions are active and what the logins are.

0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:snowycanada
ID: 34897395
Did as Lundnak's suggestion. One more question: Why is still TODO <PRODUCT NAME> ?THE RESULT OF SP_WHO2
0
 

Author Comment

by:snowycanada
ID: 34899201
Hi Lundnak,
the error msg "invalid object message" is replaced by "Type mismatch", after I create a new procedure pSupCheck, and I copied the old procedure code into new one. The procedure looks like working, but why it coms out the error message mismatch? I delete all the code in new procedure, it still mismatch. Is it because some setting error?
0
 
LVL 7

Accepted Solution

by:
lundnak earned 500 total points
ID: 34899534
I noticed that the parameter fields for the sproc are Nvarchar, but in your code you are using adVarChar.  That is likely the issue.  You need to change one or the other.  
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question