|
Thanks to both for your pointers.
|
|
|
|
|
I'm converting some old CDao classes to ADO (ODBC) for Access database handling. Part of my code copies a table record from one database to another. When I do the CRecordset::Update I get a CDBException that completely unhelpfully tells me:
m_strError "String data, right truncated
m_strStateNativeOrigin "State:22001,Native:31,Origin:[Microsoft][ODBC Microsoft Access Driver]
Is there any way to get my code to tell me which field(s) is(are) causing the problem?
|
|
|
|
|
Kyudos wrote: right truncated
I would check the length of everything, data, parameter, target field in the table.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I tried that...I can't find it!
Surely the driver must 'know' where this happens - why can't it just tell me?
|
|
|
|
|
It is the same with SQL Server and has always been an irritant. With SQL Server you have sql profiler and you can trap the actual statement passed to the database including data. You can then manually execute the command in management studio. This gives you a more detailed error response and you can use the mark I eyeball to inspect the data.
I know you can execute sql strings in Access but I do not know where to trap the command passed to the database from the client.
I would strongly suggest moving the database from Access to SQL server if possible.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I would strongly suggest moving the database from Access to SQL server if possible. That's impractical unfortunately.
I've checked all the text field member lengths before and after the Update, they both match each other and the database definition. The are no problems in DoFieldExchange . I don't know what to do next...
|
|
|
|
|
Hah!
My fault of course - I was checking the wrong database definition - I had a field the wrong length!
oops!
|
|
|
|
|
Yah, done that well... yesterday actually!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello everyone,
I would like to know if there is a function that can get rid of a 1000 seperator.
My Source data looks like this
1.676
3.349
109
58
70
1.887
I would like it to be like this:
1676
3349
109
58
70
1887
Does anyone know how I can fix this in my following statement please?
, CASE COALESCE(SHIPPED_VAL_MONTH, '') WHEN '' THEN 0 ELSE CAST(SHIPPED_VAL_MONTH as decimal(18,2)) END AS SHIPPED_VAL_MONTH
Kind regards,Ambertje
|
|
|
|
|
From sqlservercentral.
Create a UDF and put this in it:
WHILE PATINDEX('%[^0-9]%',@string) <> 0
SET @string = STUFF(@string,PATINDEX('%[^0-9]%',@string),1,'')
SELECT @string
|
|
|
|
|
Hello Jörgen,
Can you help me to create such a User defined function for my case please?
I have little experiece with writing functions.
Kind regards,
Ambertje
|
|
|
|
|
You are going to get better value out of an article than a forum post, there is even one from CP in these results[^]
Ambertje wrote: help me to create such a User defined function
That is not how the site works, we help you to learn how to create the functions, there are other sites that will do the job for you.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
plz help me to create pdf from xml code manually
|
|
|
|
|
i have a table with students marks records which contains the data as follows:
admno subjectGroup Exam subject marks
4719 GROUP I CAT-01 ENGLISH 45
4719 GROUP I CAT-01 KISWAHILI 78
4719 GROUP II CAT-01 CHEMISTRY 67
4719 GROUP II CAT-01 BIOLOGY 45
4719 GROUP II CAT-01 PHYSICS 45
4719 GROUP I CAT-01 MATHEMATICS 90
4720 GROUP I CAT-01 ENGLISH 67
4720 GROUP I CAT-01 KISWAHILI 61
4720 GROUP I CAT-01 MATHEMATICS 77
4721 GROUP I CAT-01 ENGLISH 81
4722 GROUP I CAT-01 KISWAHILI 62
4723 GROUP I CAT-01 ENGLISH 89
4724 GROUP I CAT-01 KISWAHILI 63
4726 GROUP I CAT-01 ENGLISH 78
4728 GROUP I CAT-01 ENGLISH 67
4730 GROUP I CAT-01 KISWAHILI 81
4734 GROUP I CAT-01 MATHEMATICS 56
i need to add marks belonging to a particular student(admno) based on the following criteria:
for each student;
1. select 3 group I subjects
2. select the best 2 group II subjects
...kindly assist
modified 13-Apr-15 16:50pm.
|
|
|
|
|
What is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
summing up marks per student(admno) based on the conditions given
|
|
|
|
|
Use a select query with a where clause on the subject group to get the group 1 students limit the output to 3 records (TSQL has a TOP function, not sure about MySQL)
For the second use the same query and change the where clause and the record limit. Add an order by on Marks to get the 2 records you need.
This is a microsoft answer, technically correct but does not meet you requirements which I suspect should have included - give me the codz!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks for the answer....but that works well for a single student but for many students it add all marks of all students
|
|
|
|
|
Ah my bad, I missed the add. You may need a nested select. First build your query to get the records you need and then wrap that in an aggregate query
select GroupID, sum(marks)
from(select GroupID, marks
From Table
Where Group = 'some code') X
group by GroupID
The query X gets the records you need and the outer query aggregates those records.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the quick reply ...i have tried but could not really succeed. i managed the following
SELECT sAdmNo ,SBGROUP ,SUM(AVG) FROM (select sAdmNo,SBGroup, AVG
From (select sAdmNo,SBGroup, AVG FROM marks Where SBGroup = 'GROUP I' LIMIT 3)AS T
Where SBGroup = 'GROUP II' LIMIT 2)AS TT GROUP BY sAdmNo
...kindly elaborate on how i can add from both groups
|
|
|
|
|
i have a picturebox with a default image and want to save image to database when it contains another image apart from the default. and if the picturebox has the default image then set in the db to null.
any suggestion on how i can check that before updating the database...
i tried using this but it doesnt check:
If Me.PictureBox1.Image Is System.Drawing.Image.FromFile(My.Application.Info.DirectoryPath & "\ImageSyntax\NoImage.JPG") Then
'action
End If
|
|
|
|
|
You might try the .NET forum.
What about checksum?
Mongo: Mongo only pawn... in game of life.
|
|
|
|
|
Hi All,
I have a stored procedure as below and I am calling that stored procedure by using ExecuteQuery in asp.net application, I am calling passing the out parameter value but still it is throwing exception. I am not understanding where am I missing, I am debugging and searching too, still can't find any answer.
Can anybody please help me in this any suggestion link or code snippet would be helpful, thanks in advance.
Here is Stored Procedure parameter structure I avoided putting all stored procedure logic here to increase readability, but if you want I can put it here
ALTER PROCEDURE [dbo].[StaffSearch_sel]
(
@OverrideSecurity BIT = 0,
@UserId INT,
@SchoolYearId INT,
@Name VARCHAR(500) = NULL,
@ContractorId INT = NULL,
@SubcontractorId INT = NULL,
@SiteId INT = NULL,
@OrganizationRelationshipIds VARCHAR(500) = NULL,
@RoleTypeIds VARCHAR(200) = NULL,
@StaffMemberNeedsAllRoles BIT = 0,
@Page INT = 1,
@RowsPerPage INT = 20,
@TotalRows INT OUT,
@SortExpression VARCHAR(50) = 'LastName',
@SortDirection VARCHAR(15) = 'Ascending'
)
AS
BEGIN
---logic-----
END
And my C# code here
public static List<StaffMemberPOCO> Search(bool staffMemberNeedsAllRoles, bool overrideSecurity, string name, int schoolYearId, int? contractorId, int? subcontractor, int? siteId,
int[] roleTypeIds, int[] organizationRelationshipIds, int userId, int pageNumber, int rowsPerPage, out int totalRows, string sortExpression, string sortDirection)
{
using (var context = new ELMSContext())
{
var outputParm = new SqlParameter("TotalRows", SqlDbType.Int) { Direction = ParameterDirection.Output };
List<StaffMemberPOCO> pocos =
context.ExecuteStoreQuery<StaffMemberPOCO>("exec StaffSearch_sel @OverrideSecurity, @UserId, @SchoolYearId, @Name, @ContractorId, @SubcontractorId, @SiteId, @OrganizationRelationshipIds, @RoleTypeIds, @StaffMemberNeedsAllRoles",
new SqlParameter("@OverrideSecurity", overrideSecurity),
new SqlParameter("@UserId", userId),
new SqlParameter("@SchoolYearId", schoolYearId),
new SqlParameter("@Name", name ?? (object)DBNull.Value),
new SqlParameter("@ContractorId", contractorId ?? (object)DBNull.Value),
new SqlParameter("@SubcontractorId", subcontractor ?? (object)DBNull.Value),
new SqlParameter("@SiteId", siteId ?? (object)DBNull.Value),
new SqlParameter("@OrganizationRelationshipIds", organizationRelationshipIds == null || organizationRelationshipIds.Count() == 0 ? (object)DBNull.Value : string.Join(",", organizationRelationshipIds)),
new SqlParameter("@RoleTypeIds", roleTypeIds == null ? (object)DBNull.Value : string.Join(",", roleTypeIds)),
new SqlParameter("@StaffMemberNeedsAllRoles", staffMemberNeedsAllRoles),
new SqlParameter("@Page", pageNumber),
new SqlParameter("@RowsPerPage", rowsPerPage),
outputParm,
new SqlParameter("@SortExpression", sortExpression ?? (object)DBNull.Value),
new SqlParameter("@SortDirection", sortDirection ?? (object)DBNull.Value)
).ToList();
totalRows = ((outputParm != null) && !DBNull.Value.Equals(outputParm)) ? int.Parse(outputParm.Value.ToString()) : 0;
return pocos;
}
}
And executestorequery is throwing the following exception
System.Data.SqlClient.SqlException: Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied.
"There is enough hatred in the world, lets spread love compassion and affection."
|
|
|
|
|
Looks like you simply forgot the @
var outputParm = new SqlParameter("@TotalRows", SqlDbType.Int) { Direction = ParameterDirection.Output };
^^^
|
|
|
|
|
Even after putting @ also it was giving me error then I tried with this.
I have put it like this
List<StaffMemberPOCO> pocos =
context.ExecuteStoreQuery<StaffMemberPOCO>("exec StaffSearch_sel @OverrideSecurity, @UserId, @SchoolYearId, @Name, @ContractorId, @SubcontractorId, @SiteId, @OrganizationRelationshipIds, @RoleTypeIds, @StaffMemberNeedsAllRoles",
new SqlParameter("@OverrideSecurity", overrideSecurity),
new SqlParameter("@UserId", userId),
new SqlParameter("@SchoolYearId", schoolYearId),
new SqlParameter("@Name", name ?? (object)DBNull.Value),
new SqlParameter("@ContractorId", contractorId ?? (object)DBNull.Value),
new SqlParameter("@SubcontractorId", subcontractor ?? (object)DBNull.Value),
new SqlParameter("@SiteId", siteId ?? (object)DBNull.Value),
new SqlParameter("@OrganizationRelationshipIds", organizationRelationshipIds == null || organizationRelationshipIds.Count() == 0 ? (object)DBNull.Value : string.Join(",", organizationRelationshipIds)),
new SqlParameter("@RoleTypeIds", roleTypeIds == null ? (object)DBNull.Value : string.Join(",", roleTypeIds)),
new SqlParameter("@StaffMemberNeedsAllRoles", staffMemberNeedsAllRoles),
new SqlParameter("@Page", pageNumber),
new SqlParameter("@RowsPerPage", rowsPerPage),
new SqlParameter("@TotalRows", SqlDbType.Int) { Direction = ParameterDirection.Output },
new SqlParameter("@SortExpression", sortExpression ?? (object)DBNull.Value),
new SqlParameter("@SortDirection", sortDirection ?? (object)DBNull.Value)
).ToList();
totalRows = ((outputParm != null) && !DBNull.Value.Equals(outputParm)) ? int.Parse(outputParm.Value.ToString()) : 0;
And still giving the following error
Procedure or function 'StaffSearch_sel' expects parameter '@TotalRows', which was not supplied.
"There is enough hatred in the world, lets spread love compassion and affection."
modified 8-Apr-15 2:25am.
|
|
|
|
|