Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone,

I am completely confused by SQLite right now.
I use the System.Data.SQLite Version for C#

I have two Tables:

Table 1:
In it I have created two columns (more but they are the important in this case and the statement is way to long to post it). The first one is called RecStat and the second one DOXinM.
Both are a Decimal and are created like this:
...
SQL
[RectStat] Decimal,
[DOXinM] Decimal,

...

The Create Table statement looks like this:
SQL
Create Table If Not Exists "Table1"
(..Columns..);

When I insert a value in this table the decimal works perfectly fine and when I read it out it works too on the xaml GUI.

After that I created a second Table which also has a Decimal Column.
I Created the table the same way (this is a short one, So i can give the whole statement)
SQL
Create Table If Not Exists "Table2" (
 [ID] Integer Not Null Primary Key,
 [Material] VarChar(10],
 [Thickness] Decimal);


In both case I do the same insert for the Decimal Column:
SQL
Insert into Table1 ('RectStat') values ('10.5');
Insert into Table1 ('DOXinM') values ('1.3');
Insert into Table2 ('Thickness') values ('0.25');


Now the Database inserts the first two Statements as 10.5/1.3 and the last one as 0,25
When I read out the value the first two works perfectly fine but the last one is shown without the numbers after the decimal "point".

So my question is.
Why does this happens?
(Btw I have more than 20 Decimals columns in my table and the "Thickness" is the only one with this problem)

I hope you can help me.

Thanks in Advance
Richard

What I have tried:

Tried different Values (Had the hope that it was because of the 0.25)
Tried it without the ''. But than the statement thought it had three values for two columns...
Posted
Updated 10-Aug-16 19:51pm
Comments
Kornfeld Eliyahu Peter 28-Jul-16 9:01am    
You wrote once 0.25 (with dot) and once 0,25 (with comma) - how it is written in your code (comma is the wrong!)
Evosoul04 28-Jul-16 9:12am    
In my Code i write it with a dot. But my database saves only this one with a comma
Kornfeld Eliyahu Peter 28-Jul-16 9:16am    
That makes no sense...
1. DB does not store dots or commas, except if it is a string, but we talking about decimals. Dots and commas are belong to the display formatting...
2. "Tried it without the ''. But than the statement thought it had three values for two columns..." - this comment makes sense only if you wrote this:
Insert into Table2 ('Thickness') values (0,25);
This line will not produce that error...
Insert into Table2 ('Thickness') values (0.25);
Evosoul04 28-Jul-16 9:19am    
Like I said, I don't understand the error. But I found a solution, I guess there was something wrong with the way I was Parameterizing my Values. I tired it the way "Björn" suggested in this link: http://stackoverflow.com/questions/809246/adding-parameters-in-sqlite-with-c-sharp
and it worked
Maciej Los 7-Aug-16 17:06pm    
So, post the answer and mark it as "solution". This will remove your question unanswered list.

1 solution

I still don't understand the error but I found a solution.
I guess there was something wrong with the way I was parameterizing my Values.

I tried what "Björn" suggested in this link: [^]

That worked for me
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900