|
-
Mar 27th, 2006, 07:40 PM
#1
[RESOLVED] String argument causes problem
I have the ff. code...
Code:
public string GetNewID(string tableName)
{
const string stringSql = "SELECT CurrentValue FROM Sequences WHERE TableName = ?";
_dataAccess.PrepareQuery(stringSql);
//_dataAccess.AddParameter("TableName", (System.String)stringTableName);
_dataAccess.AddWhereParameter("TableName", "EmployeeID");
int result = (int)_dataAccess.GetFieldValue;
// Since I am formating the result with 5 0's (00000) I have to check
// whether I have reach passed 5 digit numbers, if I have then
// I should reset it to one.
if (result.Equals(100000))
{
const string stringUpdateSequence = "UPDATE Sequences SET CurrentValue = 1 WHERE TableName = ?";
_dataAccess.PrepareQuery(stringUpdateSequence);
_dataAccess.AddParameter("TableName", "EmployeeID");
_dataAccess.ExecuteActionQuery();
}
int currentValue = _dataAccess.GetNextSequenceNumber("EmployeeID");
return string.Format("{0:yy-MM}-{1:00000}", DateTime.Now, currentValue);
}
t is called by:
Code:
public static string GetNewCode()
{
string newCode = _dataPortal.GetNewID("EmpoyeeID");
return newCode;
}
If you may notice I have a parameter tableName which I intend to fill the value for the parameters I would pass like...
Code:
_dataAccess.AddWhereParameter("TableName", tableName);
Problem is if I do that it causes an error, I can't get the ...
Code:
(int)_dataAccess.GetFieldValue
To work since it is returning a null value, whereas if I hardcode it all is working well, what seems to be the problem? This is really strange...
-
Mar 27th, 2006, 07:59 PM
#2
Re: String argument causes problem
I don't understand this:
Code:
_dataAccess.AddParameter("TableName", (System.String)stringTableName);
Your argument is named 'tableName', not 'stringTableName', and it is already a String so why the cast?
-
Mar 27th, 2006, 08:00 PM
#3
Re: String argument causes problem
 Originally Posted by jmcilhinney
I don't understand this:
Code:
_dataAccess.AddParameter("TableName", (System.String)stringTableName);
Your argument is named 'tableName', not 'stringTableName', and it is already a String so why the cast?
Ooopppsss... That is commented out, was just trying to cast it to string if it would work, and I just changed the variable name, sorry if I didn't remove it...
-
Mar 27th, 2006, 08:19 PM
#4
Re: String argument causes problem
So previously you were doing this:
Code:
_dataAccess.AddParameter("TableName", tableName);
and it wouldn't work?
-
Mar 27th, 2006, 08:36 PM
#5
Re: String argument causes problem
Yes, my method is returning null...
-
Mar 27th, 2006, 08:44 PM
#6
Re: String argument causes problem
string newCode = _dataPortal.GetNewID(" EmpoyeeID");
Could it be that you can't spell?
-
Mar 27th, 2006, 09:36 PM
#7
Re: String argument causes problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|