Solved

invalid object name 'dbo.pSupervisorCheck_EOL'

Posted on 2011-02-14
6
575 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now