|
In a C# 2008 desktop application, I have the following statement that give when an error when the code points to a different database:
eRPTDataContext rptDataaddRVW = new eRPTDataContext();
var eRPTaddRVW = (from a in rptDataaddRVW.eRPT_Transaction_Trackings
where a.Package_ID == packageId
select a).FirstOrDefault();
Here is the error message I get:
2013-02-04 16:13:15.3731|ERROR|erptsampleclient.eRPTSample|Error Processing --> Specified cast is not valid.
2013-02-04 16:13:15.3731|ERROR|erptsampleclient.eRPTSample|************* Stack Trace *******************
2013-02-04 16:13:15.3887|ERROR|erptsampleclient.eRPTSample| at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at erptsampleclient.eRPTSample.addNewReviewPackage() in C:\_svn\Cas_client\erptsampleclient\eRPTSample.cs:line 1308
2013-02-04 16:13:15.3887|ERROR|erptsampleclient.eRPTSample|Error Processing --> Specified cast is not valid.
2013-02-04 16:13:15.3887|ERROR|erptsampleclient.eRPTSample|************* Stack Trace *******************
2013-02-04 16:13:15.4043|ERROR|erptsampleclient.eRPTSample| at erptsampleclient.eRPTSample.addNewReviewPackage() in C:\_svn\Cas_client\erptsampleclient\eRPTSample.cs:line 1369
at erptsampleclient.eRPTSample.Main(String[] args) in C:\_svn\Cas_client\erptsampleclient\eRPTSample.cs:line 154
2013-02-04 16:13:23.3135|INFO|erptsampleclient.eRPTSample|******************ADD (CREATE) REVIEW (RVW) (METHOD 2 CALL)**********************
2013-02-04 16:13:28.8359|INFO|erptsample.ERPTProxy|The number of attachments in the list are ->1
2013-02-04 16:13:54.2171|INFO|erptsample.ERPTProxy|add review package successfully for rvw pkg id: RVW0204201300524 return code = 0
2013-02-04 16:13:58.5227|INFO|erptsampleclient.eRPTSample|Review Package was created successfully for Package id: RVW0204201300524
2013-02-04 16:13:58.5695|ERROR|erptsampleclient.eRPTSample|Error Processing --> Specified cast is not valid.
2013-02-04 16:13:58.5695|ERROR|erptsampleclient.eRPTSample|************* Stack Trace *******************
2013-02-04 16:13:58.5851|ERROR|erptsampleclient.eRPTSample| at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
When I change the code to the following:
var eRPTaddRVW = (from a in rptDataaddRVW.eRPT_Transaction_Trackings
where a.Package_ID == packageId
select new { erptPackageID = a.Package_ID, erptFileLocation = a.File_Location }).FirstOrDefault();
M
I do not get an error.
The problem is I want to be able to update the database row I just accessed and the linq will not compile clean to let me do that.
I am getting the follwowing error message when I try to access a specific field:
Error 10 'object' does not contain a definition for 'erptFileLocation' and no extension method 'erptFileLocation' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) C:\_svn\Cas_client\erptsampleclient\eRPTSample.cs 1320 56 ERPTsampleclient
Here is the code I am trying to add:
if (eRPTaddRVW != null)
{
eRPTaddRVW.erptFileLocation = RVWFile;
rptDataaddRVW.SubmitChanges();
}
Can you tell me what I can do to solve my problem?
|
|
|
|
|
dcof wrote: 2013-02-04 16:13:15.3887|ERROR|erptsampleclient.eRPTSample|Error Processing --> Specified cast is not valid.
this line of the stack trace shows that you have a conversion problem from the database into the table, I would make sure that your property types are set correctly
dcof wrote: var eRPTaddRVW = (from a in rptDataaddRVW.eRPT_Transaction_Trackings
where a.Package_ID == packageId
select new { erptPackageID = a.Package_ID, erptFileLocation = a.File_Location }).FirstOrDefault();
if you put a watch on the eRPTaddRVW and then expand the results do you see any results? or do you see empty properties?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
The following is empty:erptFileLocation = a.File_Location.
I want to update the value of the field called File_Location.
Can you tell me how to rewrite the following statement so that it will let me update the File_Location field. It's property is read-only.
|
|
|
|
|
Hi,
Can anyone guide me how to write the code for digital outputs for stepper motor. I just want to run motor clockwise and to do 4 rotations and then I want it to rotate counter clockwise and to do four anti-clockwise rotations. I am using Fez mini and for driver, I am using IFR530 MOSFET circuit.
|
|
|
|
|
Not from that little we can't.
We have no idea what interface circuitry you have between the PC and the IRF530 (I assume you miss-typed) - you certainly can't connect one of them directly to a standard PC output!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
Ok, I will try to explain my circuit. I have 4 IFR530, which are going to the unipolar stepper motor. These 4 MOSFETs are connected to Digital I/Os of FEz Mini (MCU) via optoisolators and some resistors. So I have to Program the FEZ mini to run the stepper motor.
|
|
|
|
|
And what does this have to do with C#?
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
It is only C# which can be used for FEZ mini(microcontroller) and without programming Fez mini won't work. I am using c# because I want to control the rotaion and direction of motor.
|
|
|
|
|
|
I thought someone here might know anything about c#?
|
|
|
|
|
It's not the C# that's the problem though, is it?
|
|
|
|
|
The problem is I don't know C# programming that is what I need help with.
|
|
|
|
|
C# is just the language to tell the FEZ board HOW to do something. Your question is more about WHAT to tell the FEZ, which we really can't help you with.
|
|
|
|
|
how to i can create a movable button in c#
|
|
|
|
|
Write code to change the X and Y coordinates as appropriate.
|
|
|
|
|
Doesn't CM have a project with an unclickable button? Should answer the OPs question.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
you can change button position by code like this:
location.X += 100;
/* LIFE RUNS ON CODE */
|
|
|
|
|
I could able to install msi file using below code and it installed sucessfully
string path = @"C:\Projects\Debug\ELSWinServInstaller.msi";
Process process = Process.Start(path);
process.WaitForInputIdle();
process.WaitForExit();
I tried to uninstall the same using below code, but its not working.
Process p = new Process();
p.StartInfo.FileName = "msiexec.exe";
p.StartInfo.Arguments = "/x \"C:\\Projects\\Debug\\ELSWinServInstaller.msi\"/qn";
p.Start();
Please let me know where I went wrong.
|
|
|
|
|
NarVish wrote: Please let me know where I went wrong.
You forgot to explain what "is not working" means. Did it start the process? Did it throw an exception?
|
|
|
|
|
"I tried to uninstall the same using below code, but its not working."
Process p = new Process();
p.StartInfo.FileName = "msiexec.exe";
p.StartInfo.Arguments = "/x \"C:\\Projects\\Debug\\ELSWinServInstaller.msi\"/qn";
p.Start();
Unistallation code is not working. It didn't throw any exception. it executed each line. but uninstallation didn't happen.
|
|
|
|
|
NarVish wrote: Unistallation code is not working. It didn't throw any exception. it executed each line. but uninstallation didn't happen.
That's a better description; now we can rule out any exceptions and focus on the rest. From where are you starting this? From a Windows-service?
You could check the eventlog for any errors. As a quick workaround, try putting the complete command in a batch-file and execute that from code.
|
|
|
|
|
Could be a permission issue.
For Vista and Windows 7, you might need to run this program as an administrator to uninstall the program.
|
|
|
|
|
I have administrator rights.
If it is permission issue, my installation code also should not work. But installation done sucessfully.
|
|
|
|
|
can you uninstall this application from a command prompt? by running the same command?
i.e.
c:\Projects\Debug\ELSWinServInstaller.msi /qn
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|