Showing posts with label existing. Show all posts
Showing posts with label existing. Show all posts

Wednesday, March 21, 2012

Odd SqlException

I'm using .NET 2.0

I designed my BLL to work as follows:

'Update existing company <System.ComponentModel.DataObjectMethodAttribute _ (System.ComponentModel.DataObjectMethodType.Update,True)> _Public Function UpdateCompany(ByVal Original_CompanyIDAs Int64, ...)As Boolean'Get current recordDim CompaniesAs biodata.CompaniesDataTable = CompaniesAdapter.GetCompanyByID(Original_CompanyID)'If no record exists, Update failsIf Companies.Count = 0Then Throw New ApplicationException("Company does not exist.")End If Dim CompanyAs biodata.CompaniesRow = Companies(0)'Set all the values to load into the database Company.CompanyName = CompanyName ...Dim RowsAffectedAs Integer = CompaniesAdapter.Update(Company)Return (RowsAffected = 1)End Function

Recently I deleted a column in my SQL database. In order to account for this change, I deleted the same column in my DAL. Then, because of the obvious compile errors that would occur if I didn't, I deleted all references to that column in my BLL. My DAL automatically creates the Update and Insert statements. Now, the error I'm getting is as follows:

Exception Details:System.Data.SqlClient.SqlException: Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.
The statement has been terminated.

Source Error:

Line 18409: System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")> _Line 18410: Public Overloads Overridable Function Update(ByVal dataRow As System.Data.DataRow) As IntegerLine 18411: Return Me.Adapter.Update(New System.Data.DataRow() {dataRow})Line 18412: End FunctionLine 18413:

Stack Trace:

[SqlException (0x80131904): Cursorfetch: The number of variables declared in the INTO list must match that of selected columns.The statement has been terminated.] System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +200 System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +104 System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping) +3042 System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows) +345 biodataTableAdapters.CompaniesTableAdapter.Update(DataRow dataRow) in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\67b7db20\aea00f88\App_Code.nf1apfb7.1.vb:18411 CompaniesBLL.UpdateCompany(Int64 Original_CompanyID, String CompanyName, String Division, String Website, Nullable`1 CompanyInactive, String CompanyInactiveReason, Nullable`1 EmployeeCount, Nullable`1 YearFounded, Nullable`1 YearStartedBiobased, Nullable`1 NAICS, String Address1, String Address2, String City, String StateCode, String Territory, String CountryCode, String Zip, String CompanyNotes, String Prefix, String FName, String LName, String Suffix, String Title, String Email, String Phone1, String PhoneType1, String Phone2, String PhoneType2, String Phone3, String PhoneType3, String UpdateType, String UpdatedBy, Int64 SecurityLevel, Int64[] Flags) in F:\App_Code\BLL\CompaniesBLL.vb:376

Now, this exception makes no sense to me because the DAL should automatically fix the update and insert statements itself, and I never directly access those statements. The error is occuring at CompaniesAdapter.Update(Company) in my code above. Any ideas?

Thanks,
BSY E-718

Turn on SQL Profiler... and watch the actual query that is being executed... that might point you in the right direction.

Monday, March 12, 2012

ODBC--Call Failed - Collation Conflict

Hi Everyone,

I am fairly new to MS-SQL so excuse my ignorance if I have any.

I am trying to add and link a new table to an existing database. I can add the database and colums and add some data into it, and even run a query on it. However, if I try to run a query using the new table and and existing table (linked) I get the following error:

ODBC--call failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot resolve collation conflict for equal to operation. (#446)

Any ideas?

my Server and SQL specs: SBS2003 & MSSQL ver 8.0what's the query you are executing?|||A Simple or Single Join Query|||post it here.|||Here is the query :

SELECT ChangeCustidLog.NewCustid, Customer.CustId, Customer.CustName
FROM ChangeCustidLog INNER JOIN Customer ON ChangeCustidLog.NewCustid = Customer.CustId;|||try this:

SELECT ChangeCustidLog.NewCustid, Customer.CustId, Customer.CustName
FROM ChangeCustidLog
INNER JOIN Customer ON
ChangeCustidLog.NewCustid COLLATE Latin1_General_CI_AS =
Customer.CustId COLLATE Latin1_General_CI_AS;|||thank you,

the query works fine with the 'collate' phrase, when run in SQL server. I am having trouble when the query runs in Access (and thats where the linked tables are)..

is there a way to fix this 'collate' problem??