Solved

invalid object name 'dbo.pSupervisorCheck_EOL'

Posted on 2011-02-14
6
581 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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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…

726 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