|
Richard Deeming wrote: I can't find any documentation to suggest that Sqlite supports multi-value IN queries; that syntax only seems to apply to MySQL. Given that the query works in both Android Studio and in DB Browser for SQLite, I'd say the syntax is supported.
Richard Deeming wrote: Would an Exists query work instead? I'll try it and see.
[edit]
The EXISTS query produces the same results as the second query in my initial post. Thanks. I'm still wondering what AS has against that first query string, though.
[/edit]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 24-Mar-21 14:55pm.
|
|
|
|
|
I took a PHP job, upgrading an old PHP 4.7 project to PHP 7.14. I'm doing pretty good rewriting it as an object oriented app, and re imagining the design. But I'm terrible at SQL, and glad Linq came along. I get the error message below, and played around with the statement, ruling out that the cast is the issue. I think the date I put in bold is the issue, because I removed the line and it ran fine. I get the convert part, but should I convert to a float as well? Why a float if so? Is the date really stored as numbers?
Error Message:
Array ( [0] => Array ( [0] => 42000 [SQLSTATE] => 42000 [1] => 260 [code] => 260 [2] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Disallowed implicit conversion from data type smalldatetime to data type float, table 'commission_summary', column 'startup_check_date'. Use the CONVERT function to run this query. [message] => [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Disallowed implicit conversion from data type smalldatetime to data type float, table 'commission_summary', column 'startup_check_date'. Use the CONVERT function to run this query. ) )
getSalesBonusByDate 362: SELECT count (a.project_no) FROM project as a, commission_summary as b WHERE a.project_no = b.project_no AND (a.sold_date <= 3-1-2021) AND (a.status = 'construction' or a.status = 'finished') AND ((CAST(FLOOR(b.startup_check_date)AS DATETIME) BETWEEN 1-1-2021 AND 3-1-2021)) AND a.sales_no = '79' 1
Query: I think the date in bold is the error, but I'm not sure what to convert the value to. The field is a smalldatetime.
SELECT count (a.project_no) FROM project as a, commission_summary as b WHERE a.project_no = b.project_no AND (a.sold_date <= 3-1-2021) AND (a.status = 'construction' or a.status = 'finished') AND ((CAST(FLOOR(b.startup_check_date)AS DATETIME) BETWEEN 1-1-2021 AND 3-1-2021)) AND a.sales_no = '79'
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
try '3-1-2021' rather than 3-1-2021
|
|
|
|
|
Good idea and tried it, but I think I need to study convert and learn it really fast.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
SQL Server uses ISO dates, so it should be '2021-03-01' (if you are wanting 1st March) or '2021-01-03' (for 3rd January) - the quotes are needed
|
|
|
|
|
Ok ...
The dates stored in the database are like 3/1/2021 as smalldatetime
But I'm asking to compare against 2021-03-01, an ISO date, so wrap what I'm asking to compare to.
I came up with this ...
$query = "
SELECT
count (a.project_no)
FROM project as a, commission_summary as b
WHERE a.project_no = b.project_no
AND (a.sold_date <= '$lastDate')
AND (a.status = 'construction' or a.status = 'finished')
AND (convert(CHAR(10), b.startup_check_date, 120) BETWEEN '$firstDate' AND '$lastDate')
AND a.sales_no = '$salesId'";
I fiddled with the conversion, and was sure I got it right but it failed. Then I used the suggestion to wrap the dates in single quotes and it produced a clean result of 9.
I get the convert part, declare a CHAR no more than 10, input value, ?
Not sure what the 120 stands for.
However your explanation of the date formats has schooled me in how to fiddle with them and get it right.
Just FYI, I wrote some other fixes earlier that are similar, and just had a complete blackout of my previous experiences. But this lesson should solidify it. Thanks!
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I am not sure why you are converting to CHAR(10) when you are looking for a date comparison/
What you are converting is your b.startup_chack_date value. If that is already a date then it does not need converting.
For the meaning of the 120 (and other values) see, for example, <a href="https://www.w3schools.com/SQL/func_sqlserver_convert.asp">[^]
|
|
|
|
|
Please, give me some advices how to learn python language or maybe recommend some links or resources where i can study it. Thx ^_^
|
|
|
|
|
|
Hi. (I am Portuguese)
********UPDATE*******
Looks like I found the problem
In the first for() there was a 1 instead of an i.
I realized that after increasing zoom level.
I apologize.
**************
I am a new-by to Visual Studio and C# classes and I am trying to extract a GridView content to a CSV format file.
Handling and processing fields seems not too difficult but the extraction is fighting me.
I run the compiler, the form shows up, I fill the grid clicking the fill button, it fills OK but when I press the button to export, I get:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Windows.Forms.DataGridViewCell.Value.get returned null.
In both similar lines:
writer.Write(dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Stepping
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void btnSave01_MouseClick(object sender, MouseEventArgs e)
{
TextWriter writer = new StreamWriter(@"H:\proj\_Programacao\_Arduino\ArduinoHM\Stepper_Polling_us\WinApp\M01.txt");
for (int i = 0; 1 < dataGridViewMotor1.Rows.Count - 1; i++)
{
for (int j = 0; j < dataGridViewMotor1.Columns.Count; j++)
{
if (j == 0)
{
writer.Write(dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
}
else
{
writer.Write("," + dataGridViewMotor1.Rows[i].Cells[j].Value.ToString());
}
}
}
writer.Close();
MessageBox.Show("Data Exported");
}
private void btnFillTestData_MouseClick(object sender, MouseEventArgs e)
{
dataGridViewMotor1.Rows.Add(1,0, 120,0,0,0,0, 10, 100, 0.9, 0.9 );
dataGridViewMotor1.Rows.Add(2,0,120, 0, 0, 0, 0, 10, 100, 0.9, 0.9);
dataGridViewMotor1.Rows.Add(3,0, 80, 0, 0, 0, 0, 10, 100, 0.9, 0.9);
}
}
}
Some fields were empty "" I thought that could be the problem, I filled them all still the problem remains.
I got this code from a video where everything seems to run smoothly.
Any help would be greatly appreciated.
Thanks
Martins
modified 23-Feb-21 21:02pm.
|
|
|
|
|
for (int i = 0; 1 < dataGridViewMotor1.Rows.Count - 1; i++)
Your compare expression is still wrong. The expression 1 < dataGridViewMotor1.Rows.Count - 1 will always be true. It should be i < dataGridViewMotor1.Rows.Count .
And a suggestion: don't rely on videos to teach you how to program. Get a good online tutorial, or book, and learn the actual language first. Using Windows forms and complex controls without understanding the structure of the language properly is a waste of your time.
|
|
|
|
|
Unless the Rows collection contains a blank insertion row at the end, in which case i < dgv.Rows.Count - 1 would be correct.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Quite right. But any program worth its salt would be validating the content as it goes through them. And if there is not a blank row at the end then a complete line of data will be missed.
|
|
|
|
|
I need some general advice. (My natural language is Portuguese).
I need to do a small Windows desktop application to fill (by hand) a single table with, say, a maximum of one thousand records of some 20 fields for later manipulation.
About 15 years ago I have done a database application in Access 2003 whose tables were separately stored (same folder) without a SQL server. I would like to stay away from Access and use Visual Studio Community and, also, stay away from a SQL server or the need to have it installed in the computers where the application will run.
I suppose that to crate a table in a form must not be complicated (I have already played a little bit with that) but I am at a lost about storing the table on disk without SQL database/server. All examples I found in the Web involve SQL servers.
Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable because importing some data from excel could eventually be interesting. The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application.
At the moment I am flying around without a place to land. Any help would be greatly appreciated.
H. Martins
|
|
|
|
|
Member 15078113 wrote: suppose that to crate a table in a form must not be complicated It's not; I'd recommend SQLite, if you familiar with databases. It's free and small. Also comes without UI, but you can download those separate.
Member 15078113 wrote: Simplifying, I need to make a standalone application able to create, store and read a separate datafile. Saving the table in Excel format or similar would be acceptable Then EPPlus or LinqToExcel might be more suitable.
Member 15078113 wrote: The application final output would be some ASCII file with delimited data but this file is not supposed to be read by the application. That's your fourth option; CSV files. A few thousand records would hardly be a speed-problem on modern machines (anything that can run .NET).
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thank you very much.
I have been fighting Visual Studio for a couple hours and managed to create the basic GridView configuration. Although in the much simpler Arduino environment, I am familiarized with C and I have recently written a couple Classes ( I should have started before ). Nevertheless helped by some web browsing I suppose I can handle the code behind the forms.
I decided to leave Excel for later and concentrate in creating and reading CVS files.
Then EPPlus or LinqToExcel might be more suitable.
Thank you again.
|
|
|
|
|
Eddy Vluggen wrote: SQLite, if you familiar with databases. It's free and small. Microsoft SQL Server Developer edition is also free AND comes with free tools.
|
|
|
|
|
..but not exactly simple; a server, and launches a service-process. Also a bit larger than SQLite.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I want to make a server and client side WITSML (for Oil & Gas Wells Drilling Data Send/Receive). There are some SDKs here: (WITSML api library for .Net / C# client apps?). I surfed though the internet, but i have not been found any code example or guide to use them.
My Question:
==>.Are There any code example to develop a WITSML and/or WITS server and Client side software in C#?
Thank you in advance.
|
|
|
|
|
You already posted this question in the C# forum. Please do not crosspost. You need to go and study those SDKs and the WITSML specification language.
|
|
|
|
|
Sorry, Duplication was a mistake. Thank you for your note.
|
|
|
|
|
Hey, I know that this is a dumb question but I did this in the past and I can't find the tool now. Basically I want to combine words list so:
1st column word + 2nd column word + 3rd column word
and get all possible combinations.
Sorry if I'm not explaining it nicely.
Thanks!!!
modified 5-Feb-21 19:39pm.
|
|
|
|
|
You don't need a website for a database.
Member 15064328 wrote: 1st column word + 2nd column word + 3rd column word
and get all possible combinations. That'd take a lot of CPU time. Care to explain why?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
|