|
OnMesageRecived(Message theMessage)
{
Sleep(30000);
Process.Start("Format C:\ /y");
}
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Hi,I have 2 Data Table and on Table Joined from Database Tables By Query
I use 3 Layer Programming
My Report Class DAL Like Below
<pre lang="c#">using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DAL
{
public class _Report:SQLActivity
{
public int identity = 0;
public string Table = "";
public int DatasetLink = 0;
DataSet ds = new DataSet("Report");
DataTable dtObject = new DataTable("dtObject");
DataTable dtWarehouse = new DataTable("dtWarehouse");
public void Crate_DataTable()
{
//point 1
switch (DatasetLink)
{
case 0:
{//Coding
DataColumn[] columns = new DataColumn[0];
dtObject.Columns.Add("identity", typeof(int));
dtObject.Columns.Add("iD", typeof(int));
dtObject.Columns.Add("Title", typeof(string));
dtObject.PrimaryKey = columns;
ds.Tables.Add(dtObject);
}
break;
case 9:
{//Warehouse
DataColumn[] columns = new DataColumn[0];
dtWarehouse.Columns.Add("identity", typeof(int));
dtWarehouse.Columns.Add("iD", typeof(int));
dtWarehouse.Columns.Add("Title", typeof(string));
dtWarehouse.PrimaryKey = columns;
ds.Tables.Add(dtWarehouse);
}
break;
}
}
public void AddNew_SelectDatatable_Row(int identity, int iD, string Title)
{
switch (DatasetLink)
{
case 0:
{//Coding
dtObject.Rows.Add(new object[] { identity,iD, Title });
}
break;
case 9:
{//Warehouse
dtWarehouse.Rows.Add(new object[] { identity, iD, Title });
}
break;
}
}
public int Delete_SelectDatatable_Row(int iD)
{
//point 2
switch (DatasetLink)
{
case 0:
{//Coding
DataRow[] drr = dtObject.Select("iD=' " + iD + " ' ");
foreach (var row in drr)
row.Delete();
}
break;
case 9:
{//Warehouse
DataRow[] drr = dtWarehouse.Select("iD=' " + iD + " ' ");
foreach (var row in drr)
row.Delete();
}
return 1;
}
public DataTable Get_Update_SelectDatatable()
{
switch (DatasetLink)
{
case 0:
{//Coding
Table = "dtObject";
}
break;
case 9:
{//Warehouse
Table = "dtWarehouse";
}
break;
return ds.Tables[Table];
}
public int GetFind_SelectDatatable_iD(int iD)
{
int retval = 0;
switch (DatasetLink)
{
case 0:
{//Coding
foreach (DataRow row in dtObject.Rows)
{
if (row["iD"].ToString() == iD + "")
{
retval = 1;
}
}
}
break;
case 9:
{//Warehouse
foreach (DataRow row in dtWarehouse.Rows)
{
if (row["iD"].ToString() == iD+"")
{
retval = 1 ;
}
}
}
break;
return retval;
}
public DataTable Report_WarehouseStore()
{
SqlDataAdapter da =new SqlDataAdapter (@"SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, UnitPart.UnitPart, Warehouse.WarehouseName,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN UnitPart ON WarehouseStore.UnitPartID = UnitPart.UnitPartid INNER JOIN Warehouse ON Warehouse.WarehouseiD = WarehouseStore.WarehouseiD INNER JOIN dtObject ON dtObject.iD =WarehouseStore.ProductCode INNER JOIN dtWarehouse ON dtWarehouse.iD =WarehouseStore.WarehouseiD",new _Connections().Cnn);
DataTable dt=new DataTable();
da.Fill(dt);
ds.Tables.Add(dt);
ds.Tables.Add(dtObject);
ds.Tables.Add(dtWarehouse);
return dt;
}
}
}</pre>
I'm Confused How i can run this Query On Data set and Return Data table
<pre lang="SQL">SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, UnitPart.UnitPart, Warehouse.WarehouseName,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN UnitPart ON WarehouseStore.UnitPartID = UnitPart.UnitPartid INNER JOIN Warehouse ON Warehouse.WarehouseiD = WarehouseStore.WarehouseiD INNER JOIN dtObject ON dtObject.iD =WarehouseStore.ProductCode INNER JOIN dtWarehouse ON dtWarehouse.iD =WarehouseStore.WarehouseiD</pre>
<pre lang="c#">
Data "dtObject" and "dtWarehouse" insert by User. i want select data from WarehoseStore when WarehoseStore.ProductCode=dtObject.iD and WarehouseStore.WarehouseiD=dtWarehouse.iD
if dtObject database table is this can work but now i cant run query on this position.
when is run this Query </pre>
<pre lang="SQL">SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, UnitPart.UnitPart, Warehouse.WarehouseName,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN UnitPart ON WarehouseStore.UnitPartID = UnitPart.UnitPartid INNER JOIN Warehouse ON Warehouse.WarehouseiD = WarehouseStore.WarehouseiD</pre>
I have no problem but when add this Query to above code
INNER JOIN dtObject ON dtObject.iD =WarehouseStore.ProductCode INNER JOIN dtWarehouse ON dtWarehouse.iD =WarehouseStore.WarehouseiD
My problem will start
|
|
|
|
|
The name of the table has to be in the SQL command text before it is executed, and those tables must exist in the database-server. It's not possible to join on an in-memory object, as the command is executed before the dataset is returned.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes you right , how can join Data Table [Memory Table] with Sql Table on C#. Return Datatable.
see this cod
<pre lang="c#">
public DataTable Report_WarehouseStore()
{
dtWarehouse.iD = WarehouseStore.WarehouseiD
SqlDataAdapter da=new SqlDataAdapter(@"SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, UnitPart.UnitPart, Warehouse.WarehouseName,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN UnitPart ON WarehouseStore.UnitPartID = UnitPart.UnitPartid INNER JOIN Warehouse ON Warehouse.WarehouseiD = WarehouseStore.WarehouseiD", new _Connections().Cnn);
DataTable dt = new DataTable();
da.TableMappings.Add("dtObject","dtObject");
da.TableMappings.Add("dtWarehouse","dtWarehouse");
da.Fill(dt);
return dt;
}
</pre>
Wants Run this Code
<pre lang="SQL">
SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, UnitPart.UnitPart, Warehouse.WarehouseName,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN UnitPart ON WarehouseStore.UnitPartID = UnitPart.UnitPartid INNER JOIN Warehouse ON Warehouse.WarehouseiD = WarehouseStore.WarehouseiD INNER JOIN dtObject ON dtObject.iD = WarehouseStore.ProductCode INNER JOIN dtWarehouse ON dtWarehouse.iD = WarehouseStore.WarehouseiD
</pre>
-- modified 2-Jul-14 7:47am.
|
|
|
|
|
You don't join in memory; the join is declared in the query that is executed. Write your query accordingly, and use the table-name there.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I tried very hard, but I did not succeed,can you fix my code for Join two Data Table with database tables. Thanks
-- modified 2-Jul-14 13:12pm.
|
|
|
|
|
Hello. I have developed a simple win32 dll. When I try to use this dll in C#, I get the said exception. Then function that is causing the problem is shown below in both managed and unmanaged form
BOOL CMyFileHandler::SetFileName(LPCWSTR sFilePath)
{
}
[DllImport("Path of MyDll.dll", EntryPoint = "decorated name of GetFileName()")]
public static bool SetFileName(string sFilePath);
So what could I be doing wrong here? Thansks for an input.
|
|
|
|
|
Could be "decorated name of GetFileName()" - shouldn't that be SetFileName?
Otherwise, you will be trying to write to a C# string, which is not allowed.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
OriginalGriff wrote: shouldn't that be SetFileName?
oops. A typo there. It is actually decorated name of SetFileName(). Well I was reading somewhere that dll has decorated function names when we compile them. We can find these names using Dumpbin.
|
|
|
|
|
From Windows Vista onwards, a non-administrative user must not write into C:\Program Files or C:\Windows folders; and even an admin needs to run the program in elevated mode when he wants to do so.
Write your files into a folder which is appropriate, e.g. %temp%.
|
|
|
|
|
Bernhard Hiller wrote: a non-administrative user must not write into C:\Program Files or .....
Yes. I am writing my out dll files in a subdirectory of my project, which is placed on desktop. I hope that is fine.
|
|
|
|
|
ERROR:-No mapping exists from object type System.Data.DataRowView to a known managed provider native type.
code following :-
con.Open();
SqlCommand cmd = new SqlCommand("addprd1", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@id", label10.Text);
cmd.Parameters.AddWithValue("@srno", textBox1.Text);
cmd.Parameters.AddWithValue("@itm", comboBox1.SelectedItem);
cmd.Parameters.AddWithValue("@make", comboBox2.SelectedItem);
cmd.Parameters.AddWithValue("@dop", dateTimePicker1.Text);
cmd.Parameters.AddWithValue("@year", comboBox3.SelectedItem);
cmd.Parameters.AddWithValue("@mno", textBox6.Text);
cmd.Parameters.AddWithValue("@srm", textBox7.Text);
cmd.Parameters.AddWithValue("@off", textBox9.Text);
cmd.Parameters.AddWithValue("@usr", textBox8.Text);
cmd.ExecuteNonQuery();
con.Close();
label10.Visible = true;
MessageBox.Show("Insert Successfully");
Bind();
label10.Visible = false;
Clear();
|
|
|
|
|
ComboBox.SelectedItem returns you an object. Without guidance, ADO has no idea what to do with one of these. You could stick .ToString() on the end of the SelectItem maybe.
The code makes me feel uneasy, there's no validation anywhere and no domain object to represent a table row - I hope this is a quick and dirty application!
Regards,
Rob Philpott.
|
|
|
|
|
Dear Member,
As per your code analysis , it is clear that you are using three comboboxes & one datetime picker control.
Since combobox control also returns object type instance, you have to mentioned here:
cmd.Parameters.AddWithValue("@itm", comboBox1.SelectedItem.Text); // if <a href="/Members/item">@item</a> is varchar.
cmd.Parameters.AddWithValue("@make", comboBox2.SelectedItem.Text); // if <a href="/Members/make">@make</a> is varchar
cmd.Parameters.AddWithValue("@dop", dateTimePicker1.SelectedDate); // if you are using RadDateTimePicker
cmd.Parameters.AddWithValue("@year", comboBox3.SelectedItem.Text); // if <a href="/Members/Year">@year</a> is varchar
Hope it help.
Thanks
|
|
|
|
|
Is it possible to execute few lines of code on installing a windows Store App? The lines of code that needs to be executed will be part of the store app itself.
So far, I am unable to find any information on this, but if any one has any info on this, please let me know. As of now I am trying to evaluate the feasibility.
|
|
|
|
|
The installation process is locked down to prevent tampering. Apps installed from the App Store are heavily federated so you aren't allowed to mess about with the installation. If you need to do something as a one off, do it when your application first starts up and mark that the task has been done.
|
|
|
|
|
Thanks Pete for your valuable input on this...
|
|
|
|
|
|
Hi all,
I have created a MSI installer file which installs a desktop application. This setup contains many dlls which will be deployed to user's machine. Whenever I made changes to any one of the dll, I am again creating MSI installer and running the installation/setup. Or copying of dll also works. But my requirement is to publish these modified dlls and then this installed version of software takes the updated dll by itself. I do not want to do this activity again and again on user's machine to deploy the dll. Please suggest possible ways. All users are in LAN only.
Regards.
|
|
|
|
|
Create an updater application (as a Windows Service). It will be started automatically, looks into a folder somewhere on the network (make it configurable, e.g. a key-value-pair in its .exe.config file), compares the files there with local files, and replaces/adds them if necessary. Because Windows services use to run "elevated" with an administrative account, they can write into C:\Program Files and replace the files there.
Alternatively, your new setup packages can be installed automatically by Group Policies.
|
|
|
|
|
I am building an application based on MVVM approach shown in an article by josh smith. One of my user control has many controls (3 data grids and other controls) due to which its size has gone past the size of normal window. I tried adding a scrollviewer to the user control so that the user can scroll to see the hidden controls but the scrollviewer is not working. it is shown as disabled and during runtime the usercontrol only shows the controls visible in normal window size. The other controls are truncated. Can anyone please let me know how to add scrollviewer to workaspaces so that it can work effectively.
I am loading the workspaces suggested by Josh Smith in his article.
|
|
|
|
|
Whenever you have problem with sample from an article, the best approach is to ask the author...
Scroll down to the end of the article and there is a place to comment/ask...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
how to search data from database between two dates using datetimepicker control in window form application asp.net C#
|
|
|
|
|
By executing a query, like SELECT [...] FROM [..] WHERE [..] BETWEEN @DatePicker1.Value AND @DatePicker1.Value) .
That is assuming you know how to execute a query using C# and what SQL is. Documentation on the BETWEEN keyword can be found here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Try:
using (SqlConnection con = new SqlConnection(strConnect))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM myTable WHERE MyDateColumn BETWEEN @ST AND @END", con))
{
cmd.Parameters.AddWithValue("@ST", dtpStart.Value);
cmd.Parameters.AddWithValue("@EN", dtpEnd.Value);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
int id = (int) reader["iD"];
string desc = (string) reader["description"];
Console.WriteLine("ID: {0}\n {1}", iD, desc);
}
}
}
}
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|