|
My database Access have 3-columns : ID (int), Doc_no(string), Rcv_date(Date). I try to filter the newest row in the rows that have same Doc_no.
i have a query for database Access :
SELECT ID, Doc_No, Rcv_Date,
FROM [SDC Documents Record] A
WHERE (ID =
(SELECT TOP 1 ID
FROM [SDC Documents Record]
WHERE (A.Doc_No = Doc_No)
ORDER BY Rcv_Date DESC))
That query still work well with Query Tool in Access, but in Query Builder in Visual Stuido 12 - C#, there are message : "Error in WHERE clause near 'ORDER'" .
I don't know why. Plesea help me to fix it
leo
|
|
|
|
|
The ( puts the ORDER BY inside your WHERE clause, you have 2x ( and 3x )
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
SELECT ID, Doc_No, Rcv_Date, FROM the last comma is wrong - but with it, the query should not run in MS Access either.
|
|
|
|
|
Does anyone have C# sample code for calling a MySQL stored procedure through SSH connection using .PEM file for the SSH password?
|
|
|
|
|
|
Hi,
I have a grid where i have to filter the columns like multiple search filter and what ever records i get in the grid i am doing export to excel in c#
Everything was went well except the date column in the grid the date column data is in this format 2014/11//15
here is my c# code which i am using to remove special characters
private void getfilterdata(string filter, out string key, out string val)
{
key = string.Empty;
val = string.Empty;
if (!string.IsNullOrEmpty(filter))
{
string[] retval2 = filter.Split(new string[] { "data" }, StringSplitOptions.RemoveEmptyEntries);
if (retval2 != null && retval2.Count() > 1 && !string.IsNullOrEmpty(retval2[1]))
{
string[] strkeys = retval2[0].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries);
if (strkeys.Length >= 3 && !string.IsNullOrEmpty(strkeys[3]))
{
key = strkeys[3];
val = RemoveSpecialCharacters(retval2[1]);
}
}
}
}
In the key its shows column name and in the val it shows data..
in the val i am getting data as 20141115.
So its not matching and while exporting its empty i am not getting any records becaus e of this
this is my code for RemoveSpecialCharacters
public static string RemoveSpecialCharacters(string str)
{
return Regex.Replace(str, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);
}
Any help plz.....
|
|
|
|
|
Are you using the Grid functions to export the content of the grid or are you exporting the underlying collection. If it is the grid then you should get the grid to reformat the date then export the data.
If you are exporting the underlying collection then it is just a matter of formatting the underlying DateTime data object. The most unambiguous format I have found to bd dd/MMMM/yyyy.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
I'm currently revisiting C# and oop after a few years programming PLCs. I'm looking at delegates and events. I was wondering what is the difference between a non-generic event handler and a generic one. Why would you use the generic one over the non-generic one. I've searched on the internet and can't find a satisfactory explanation.
Thanks in advance
|
|
|
|
|
|
My application is for Leave Module. now in that i used, employee can apply leave normally Seek Leave, Casual Leave and Paid leave. but Now i have to put condition like if total leave days(Count) is less than or equal to 2 then it will automatically goes in CL n PL will be invisible in drop down list. so what can i do for that?
|
|
|
|
|
Filter the underlying collection based on the number of days asked/available. To do this you trap the change event on the requesting control and then filter the collection accordingly.
More specific help will require more detail on the UI you are using.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ok. I can understood. now i have change event on no of days calculation button. but what can i put a condition for that. can u help me in coding.
|
|
|
|
|
Member 11221185 wrote: can u help me in coding Coding what! I have no idea of your data structure, the technology you are using. For all I know you may be coding for an iPhone.
We don't do the coding for you, you will get help if you show the code YOU have written and have a problem with.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Need a simple 2D graph library for C# console app. Thanks for any ideas.
sundownr
|
|
|
|
|
And?
Google not working today?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Google works fine and after trying a few libraries I did not find what I wanted... thus I asked for any ideas. I am trying SharpDX now but prefer something simpler. All I need to do is graph a series of voltages.
sundownr
|
|
|
|
|
Are you looking to manipulate a Charting library from a Console App: I mean what else could you do in the Console but read a file into some data structure(s), manipulate the data, call the library's facilities for creating a chart passing in the data, save the resulting output chart/graphic to a file ?
Why not create a WinForms app where you can preview the chart/image you create ?
«At the still point of the turning world. Neither flesh nor fleshless;
Neither from nor towards; at the still point, there the dance is
...
Neither ascent nor decline. Except for the point, the still point,
There would be no dance, and there is only the dance»
T.S. Elliot, The Four Quartets: "Burnt Norton"/xml>
modified 14-Nov-14 13:12pm.
|
|
|
|
|
Good description of graphing with the console. I asked this question myself and then posted my question. Unless the magic answer appears I guess I am stuck with Windows forms using DirectX. It sure would be nice to draw a simple graph with minimal code. Thanks for the thought... it clarified the issue. Note... I tried the "A simple C# library for graph plotting," here on the Code Project, but was unable to find the sample code the author referred to.
sundownr
|
|
|
|
|
Well, I can't see a downside to using a WinForm app, but what you want is what you want
Check this example out: [^]. It uses System.Windows.Forms.DataVisualization.Charting; from within a Console App.
I am under the impression there are many articles on Charting/Graphing in WinForms here on CP.
cheers, Bill
«The greater the social and cultural distances between people, the more magical the light can spring from their contact» Milan Kundera, "Testaments Trahis"
|
|
|
|
|
Thanks... I will give it a try.
sundownr
|
|
|
|
|
using System;
using System.Collections.Generic;
class Program {
static void Main( string[] args ) {
List<int> voltages = new List<int>() { 10, 4, 15, 7, 20 };
int n = 0;
foreach ( int voltage in voltages ) {
Console.WriteLine( "Voltage {0}: {1}", ++n, "".PadRight( voltage, '*' ) );
}
}
}
|
|
|
|
|
Thanks Gerry... I can use this. This is as simple as it can get.
sundownr
|
|
|
|
|
Hi All,
I am using Visual Studio 2008 to design windows form Application.
I created one form, that will Browse and select excel file and by clicking on Export button, all data will transfer to sql database.
But while debugging, it stop at code
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
For your review i am giving full code below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Data.Common;
namespace CHD_CALL_REGISTER
{
public partial class Form1 : Form
{
SqlConnection con = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
string str = "Data Source=INLGM84MV1;Initial Catalog=CHD;Integrated Security=True";
SqlConnection con = new SqlConnection(str);
}
public Form1()
{
InitializeComponent();
}
private void buttonBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "C:\\";
openFileDialog1.Title = "Browse Excel Files";
openFileDialog1.CheckFileExists = true;
openFileDialog1.CheckPathExists = true;
openFileDialog1.DefaultExt = "xls";
openFileDialog1.Filter = "Excel file (*.xls)|*.xls";
openFileDialog1.RestoreDirectory = true;
openFileDialog1.ReadOnlyChecked = true;
openFileDialog1.ShowReadOnly = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.SafeFileName;
buttonexport.Enabled = true;
}
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
buttonexport.Enabled = false;
}
}
private void buttonexport_Click(object sender, EventArgs e)
{
string excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source" + textBox1.Text + ";Extended Properties\"Excel 8.0;HDR=YES\"";
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select * FROM [Sheet1$]", connection);
connection.Open();
using (DbDataReader dr = command.ExecuteReader())
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(con))
{
bulkCopy.DestinationTableName = "EMP_TABLE";
bulkCopy.ColumnMappings.Add("EMPCODE", "EMPCODE");
bulkCopy.ColumnMappings.Add("EMP_NAME", "EMP_NAME");
bulkCopy.ColumnMappings.Add("BUSINESS_CODE", "BUSINESS_CODE");
bulkCopy.ColumnMappings.Add("JOIN_DT", "JOIN_DT");
bulkCopy.ColumnMappings.Add("HQ_NAME", "HQ_NAME");
bulkCopy.ColumnMappings.Add("ZONE_ID", "ZONE_ID");
bulkCopy.ColumnMappings.Add("DESIG", "DESIG");
bulkCopy.ColumnMappings.Add("BAND", "BAND");
bulkCopy.ColumnMappings.Add("DEPT_NAME", "DEPT_NAME");
bulkCopy.ColumnMappings.Add("EMP_STATUS", "EMP_STATUS");
bulkCopy.ColumnMappings.Add("SUP1", "SUP1");
bulkCopy.ColumnMappings.Add("SUP1NAME", "SUP1NAME");
bulkCopy.ColumnMappings.Add("SUP1HQ", "SUP1HQ");
bulkCopy.ColumnMappings.Add("SUP2", "SUP2");
bulkCopy.ColumnMappings.Add("SUP2NAME", "SUP2NAME");
bulkCopy.ColumnMappings.Add("SUP2HQ", "SUP2HQ");
bulkCopy.ColumnMappings.Add("SUP3", "SUP3");
bulkCopy.ColumnMappings.Add("SUP3NAME", "SUP3NAME");
bulkCopy.ColumnMappings.Add("SUP3HQ", "SUP3HQ");
bulkCopy.WriteToServer(dr);
MessageBox.Show("Data Exported To Sql Server Successfully");
}
}
}
}
}
}
Please help me...thanks in advance...
Vishal
|
|
|
|
|
Member 11134954 wrote: But while debugging, it stop at code After which point it will throw an exception with some valuable information.
Your connection-string is broken. It should read DataSource= . It'd be cleaner if you use a string.format to get your variable in there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|