|
Hi, I have one table on database and 2 data table on Program. I want join Tables with Data table
Database Table Name WarehouseStore
Field = WarehouseStoreiD,WarehouseiD, ProductiD, ProductName,ProductValue
Datatable 1 Name: dtProduct
Field = identity,iD
Datatable 2 Name: dtWarehouse
Field = identity,iD
How Can I Join them like this code on Join Sql Tables?
SELECT WarehouseStore.ProductID, WarehouseStore.ProductCode, WarehouseStore.ProductName, ,WarehouseStore.ProductValue FROM WarehouseStore INNER JOIN dtProduct ON dtProduct.iD =WarehouseStore.ProductCode INNER JOIN dtWarehouse ON dtWarehouse.iD =WarehouseStore.WarehouseiD
-- modified 7-Jul-14 5:18am.
|
|
|
|
|
Execute the query with the JOIN on the database BEFORE you load it into a datatable.
Why do you insist on doing it after loading it in a datatable?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i can Load data warehouseStore on DataTable and insert user Data on 2 other DataTable bout I cant Join table with DataTable For show Report.
data table dtProduct Include data user select product and dtWarehouse Include data user select Warehouse and WarehouseStore Table Include All Warehouse Data.
when user insert into dtProduct ProductiD and Insert into dtWarehouse WarehouseiD must select just data on WarehouseStore When Equals to User Insert Data.
|
|
|
|
|
Mohammad Soleimani wrote: i can Load data warehouseStore on DataTable and insert user Data on 2 other
DataTable bout I cant Join table with DataTable For show Report. Why not? What error is it showing?
Can you execute the query from Sql Managment Studio to verify that it is correct?
..and yes, the result of the query would be loaded into a single datatable; that's what a join would do. Can you show the code where you execute the sql and read it into memory?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi,when i add datatable on Query Error show "invalid Object name 'dtProduct'.
i execute my Query on Sql Management studio its run perfect without datatable,
this is All Code
<pre lang="c#">
public DataTable Report_WarehouseStore()
{
DataTable dtProduct = new DataTable("dtProduct");
DataTable dtWarehouse = new DataTable("dtWarehouse");
DataTable dtResult = new DataTable("dtResult");
DataSet ds = new DataSet("Report");
DataColumn[] columns_p = new DataColumn[0];
dtProduct.Columns.Add("identity", typeof(int));
dtProduct.Columns.Add("iD", typeof(int));
dtProduct.Columns.Add("Title", typeof(string));
dtProduct.PrimaryKey = columns_p;
ds.Tables.Add(dtProduct);
dtProduct.Rows.Add(new object[] {1,1,"Iphone 6"});
DataColumn[] columns_w = new DataColumn[0];
dtWarehouse.Columns.Add("identity", typeof(int));
dtWarehouse.Columns.Add("iD", typeof(int));
dtWarehouse.Columns.Add("Title", typeof(string));
dtWarehouse.PrimaryKey = columns_w;
ds.Tables.Add(dtWarehouse);
dtWarehouse.Rows.Add(new object[] {1,1,"Central Warehouse"});
ds = ExecuteDataset(System.Data.CommandType.Text,@"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 dtProduct ON dtProduct.iD = WarehouseStore.ProductCode INNER JOIN dtWarehouse
ON dtWarehouse.iD = WarehouseStore.WarehouseiD", null);
return ds.Tables[0];
}
</pre>
|
|
|
|
|
The SQL=query does not accept variables from C# code. You'll have to find another way to do it. Thinking about it, it'll probably be simply called "Product" in the database-server, not "dtProduct". Try changing that
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi, i know "SQL=query does not accept variables from C# code" Actually this is my problem! how i can join datatable with Table ? do you have any solution for this work? thanks a lot!
|
|
|
|
|
Dear Group Members,
I am using Lucene.net for building a search engine. In course of development I came across providing filters to the search.
As I went through the Lucene documentation I came across ChainedFilter. It is a way to combine multiple filters together. However this class is not available in any of the assemblies (ver 3.0.3). The same is confirmed by multiple blog-posts. But I didn't come across any post where it is mentioned, what can be the performant way to club multiple filters together and provide it to Search().
Can someone please provide some input related to this.
Regards,
Shubhanshu
|
|
|
|
|
Lucene.net Mailing Lists[^] is where you go to ask the community of Lucene.net developers. You're not going to find a larger group of people who have used that library anywhere else.
|
|
|
|
|
Thanks Dave.
I have contacted in the specified forum by you.
Regards,
Shubhanshu
|
|
|
|
|
i'am trying to opening sub form but main form must be reduce how to add the code
I'am write using C# 2008.Thanks
Program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Linq;
namespace Mail_Gmail
{
static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main_Form());
}
}
}
Main_Form.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Main_Form
{
public partial class Main_Form : Form
{
public Main_Form()
{
InitializeComponent();
}
private void HelpToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 fo = new Form2();
fo.ShowDialog();
}
private void menuToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void enkripsiDanDekripsiToolStripMenuItem_Click(object sender, EventArgs e)
{
Form1 fo = new Form1();
fo.ShowDialog();
}
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
private void ExitToolStripMenuItem1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do You want to close ???", "Confirm",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Application.Exit();
}
}
private void MessageSendToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void emailAttachmentToolStripMenuItem_Click(object sender, EventArgs e)
{
Form4 fo = new Form4();
fo.ShowDialog();
}
private void ExitToolStripMenuItem2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do yo want to close ini ???", "Confirm",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Application.Exit();
}
}
private void GmailToolStripMenuItem1_Click(object sender, EventArgs e)
{
Form1 fo = new Form1();
fo.ShowDialog();
}
private void SendToToolStripMenuItem_Click(object sender, EventArgs e)
{
Form5 fo = new Form5();
fo.ShowDialog();
}
private void UseThisApplicationToolStripMenuItem_Click(object sender, EventArgs e)
{
Form2 fo = new Form2();
fo.ShowDialog();
}
}
}
|
|
|
|
|
Simple:
MyForm mf = new MyForm();
Hide();
mf.ShowDialog();
Show();
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 – ∞)
|
|
|
|
|
Thanks
|
|
|
|
|
KaKoten wrote: i'am trying to opening sub form but main form must be reduce how to add the code You mean "minimized"? I wouldn't recommend that, as a minimized form should not be displaying stuff.
You might want to set the parent of the sub-form though;
fo.ShowDialog(this);
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks for the answer
|
|
|
|
|
When I load my page it shows error:
<pre>Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'UserInfoaa' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 176: }
Line 177:
Line 178: public virtual UserInfoaa UserInfoaa {
Line 179: get {
Line 180: return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c367d58a\7b408850\App_Code.d_07k52h.1.cs Line: 178 </pre>
My default.aspx Code is:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.Profile;
using System.Text;
namespace WebApplication2
{
public partial class Dfault : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void submit_Click(object sender, EventArgs e)
{
MembershipCreateStatus createStatus;
MembershipUser newUser = Membership.CreateUser(username.Text, password.Text, email.Text, null, null, true, out createStatus);
saveprofile();
}
public void saveprofile()
{
ProfileCommonaa Profile = new ProfileCommonaa();
Profile.UserInfoaa.Name = name.Text;
Profile.Save();
}
}
}</pre>
My UserInfoaa class code is:
<pre lang="css">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace WebApplication2
{
[Serializable()]
public class UserInfoaa
{
#region variables
private string name;
private string dateofbirth;
private string birthplace;
private string place;
private string languages;
private string aboutme;
private string employer;
private string project;
private string designation;
private string university;
#endregion variables
#region Properties
public string Name
{
get { return name; }
set { name = value; }
}
public string DateofBirth
{
get { return dateofbirth; }
set { dateofbirth = value; }
}
public string Languages
{
get { return languages; }
set { languages = value; }
}
public string BirthPlace
{
get { return birthplace; }
set { birthplace = value; }
}
public string Place
{
get { return place; }
set { place = value; }
}
public string AboutMe
{
get { return aboutme; }
set { aboutme = value; }
}
public string Employer
{
get { return employer; }
set { employer = value; }
}
public string Project
{
get { return project; }
set { project = value; }
}
public string Designation
{
get { return designation; }
set { designation = value; }
}
public string University
{
get { return university; }
set { university = value; }
}
#endregion Properties
#region Constructors
public UserInfoaa()
{
}
public UserInfoaa(string _name, string _dateofbirth, string _birthplace, string _place, string _languages, string _aboutme, string _employer, string _project, string _designation, string _university)
{
name = _name;
dateofbirth = _dateofbirth;
birthplace = _birthplace;
place = _place;
languages = _languages;
aboutme = _aboutme;
employer = _employer;
project = _project;
designation = _designation;
university = _university;
}
#endregion Constructors
}
}</pre>
Class1 for ProfileCommonaa is:
<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Text;
using System.Web.Security;
using System.Web.UI;
namespace WebApplication2
{
public class ProfileGroupBasicInfoaa : System.Web.Profile.ProfileGroupBase
{
public virtual string Place
{
get
{
return ((string)(this.GetPropertyValue("Place")));
}
set
{
this.SetPropertyValue("Place", value);
}
}
public virtual string BirthPlace
{
get
{
return ((string)(this.GetPropertyValue("BirthPlace")));
}
set
{
this.SetPropertyValue("BirthPlace", value);
}
}
public virtual System.DateTime DateofBirth
{
get
{
return ((System.DateTime)(this.GetPropertyValue("DateofBirth")));
}
set
{
this.SetPropertyValue("DateofBirth", value);
}
}
public virtual string Name
{
get
{
return ((string)(this.GetPropertyValue("Name")));
}
set
{
this.SetPropertyValue("Name", value);
}
}
public virtual string AboutMe
{
get
{
return ((string)(this.GetPropertyValue("AboutMe")));
}
set
{
this.SetPropertyValue("AboutMe", value);
}
}
public virtual string Languages
{
get
{
return ((string)(this.GetPropertyValue("Languages")));
}
set
{
this.SetPropertyValue("Languages", value);
}
}
}
public class ProfileGroupProfessionlProfileaa : System.Web.Profile.ProfileGroupBase
{
public virtual string Designation
{
get
{
return ((string)(this.GetPropertyValue("Designation")));
}
set
{
this.SetPropertyValue("Designation", value);
}
}
public virtual string Employer
{
get
{
return ((string)(this.GetPropertyValue("Employer")));
}
set
{
this.SetPropertyValue("Employer", value);
}
}
public virtual string University
{
get
{
return ((string)(this.GetPropertyValue("University")));
}
set
{
this.SetPropertyValue("University", value);
}
}
public virtual string Project
{
get
{
return ((string)(this.GetPropertyValue("Project")));
}
set
{
this.SetPropertyValue("Project", value);
}
}
}
public class ProfileCommonaa : System.Web.Profile.ProfileBase
{
public virtual string Employer
{
get
{
return ((string)(this.GetPropertyValue("Employer")));
}
set
{
this.SetPropertyValue("Employer", value);
}
}
public virtual string Name
{
get
{
return ((string)(this.GetPropertyValue("Name")));
}
set
{
this.SetPropertyValue("Name", value);
}
}
public virtual string Place
{
get
{
return ((string)(this.GetPropertyValue("Place")));
}
set
{
this.SetPropertyValue("Place", value);
}
}
public virtual string Languages
{
get
{
return ((string)(this.GetPropertyValue("Languages")));
}
set
{
this.SetPropertyValue("Languages", value);
}
}
public virtual UserInfoaa UserInfoaa
{
get
{
return ((UserInfoaa)(this.GetPropertyValue("UserInfoaa")));
}
set
{
this.SetPropertyValue("UserInfoaa", value);
}
}
public virtual string AboutMe
{
get
{
return ((string)(this.GetPropertyValue("AboutMe")));
}
set
{
this.SetPropertyValue("AboutMe", value);
}
}
public virtual string Project
{
get
{
return ((string)(this.GetPropertyValue("Project")));
}
set
{
this.SetPropertyValue("Project", value);
}
}
public virtual string BirthPlace
{
get
{
return ((string)(this.GetPropertyValue("BirthPlace")));
}
set
{
this.SetPropertyValue("BirthPlace", value);
}
}
public virtual System.DateTime DateofBirth
{
get
{
return ((System.DateTime)(this.GetPropertyValue("DateofBirth")));
}
set
{
this.SetPropertyValue("DateofBirth", value);
}
}
public virtual string Designation
{
get
{
return ((string)(this.GetPropertyValue("Designation")));
}
set
{
this.SetPropertyValue("Designation", value);
}
}
public virtual string University
{
get
{
return ((string)(this.GetPropertyValue("University")));
}
set
{
this.SetPropertyValue("University", value);
}
}
public virtual ProfileGroupBasicInfoaa BasicInfo
{
get
{
return ((ProfileGroupBasicInfoaa)(this.GetProfileGroup("BasicInfo")));
}
}
public virtual ProfileGroupProfessionlProfileaa ProfessionlProfile
{
get
{
return ((ProfileGroupProfessionlProfileaa)(this.GetProfileGroup("ProfessionlProfile")));
}
}
public virtual ProfileCommonaa GetProfileaa(string username)
{
return ((ProfileCommonaa)(ProfileBase.Create(username)));
}
}
}</pre>
Please help! thanks in advance
|
|
|
|
|
Quote: are you missing a using directive or an assembly reference? Add the assembly (dll) where UserInfoaa is defined.
Make sure that that assembly does not have a "zone identifier" with the value of "Internet" (on the level of the NTFS file system).
|
|
|
|
|
how to adding code message box to successful message sending and i'am have to failed sent but successful nothing. this is the source code use c# 2008. Thanks for help me
private void button_Send(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == quot;" || textBox3.Text == "")
{
MessageBox.Show("Please Fill Required field");
}
else
try
{
obj_SMTPClient = new SmtpClient("smtp.gmail.com");
Obj_MailMsg = new MailMessage();
obj_Attachment = new System.Net.Mail.Attachment(label3.Text);
Obj_MailMsg.From = new MailAddress(textBox1.Text);
Obj_MailMsg.To.Add(textBox3.Text);
Obj_MailMsg.Body = textBox5.Text;
Obj_MailMsg.Attachments.Add(obj_Attachment);
Obj_MailMsg.Subject = textBox4.Text;
SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
obj_SMTPClient.Credentials = new NetworkCredential();
obj_SMTPClient.Port = 587;
obj_SMTPClient.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
}
catch
{
MessageBox.Show("Sorry TimeOut");
}
}
|
|
|
|
|
Try:
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
MessageBox.Show("Sent successfully");
}
catch
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 – ∞)
|
|
|
|
|
|
You're welcome!
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 – ∞)
|
|
|
|
|
|
Hi ALL !
I want to execute this by OledbDataReader when I want to take ... :
string CalcQuery = @"SELECT SUM(BuyAmount) From SubTblMetal WHERE IDMetal=" + int.Parse(txtId.ToString());
OleDbCommand cmdCacl;
cnnCalc.Open();
cmdCacl = new OleDbCommand(CalcQuery, cnnCalc);
OleDbDataReader dr;
dr = cmdCacl.ExecuteReader();
if (dr.HasRows==false)
{
txtBuyAmount.Text = "0";
throw new Exception();
}
else if (dr.Read())
{
txtBuyAmount.Text = dr[0].ToString();
}
But when my DataReader has not any row ,I have an error for the value of txtBuAmount.Text
please Help , how can get the value of Zero (0) , when dataRow has not any row(value).
Thanks a lot !
|
|
|
|
|
First off, please use a parameterized query rather than concatenating the value into the statement.
Next, don't trust HasRows.
Also, why is that throw in there?
As you are expecting at most one value, you might do better with ExecuteScalar and then test for DBNull.Value (for when ther are no matching records).
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Very nicely explained
If You Never Try You’ll Never Know
|
|
|
|
|