|
Hi, I have created a class customer and where I am fetching all the records from the customer table through the procedure. Now I want to fetch all the distinct city from the customer table.
Here is the code
p
ublic List<City> GetAllDistinctCity()
{
EntityDataMode entity = new EntityDataMode (Connection.ConnectionString);
try
{
var collection = entity.GetAllCustomer();
}
catch (Exception ex)
{
}
}
If I create the view for the city, then I can directory fetch all the distinct city through the procedure, but I do not want to create any separate view for only city, which is a field of a customer table, because later I need to fetch another distinct field, then I have to again create a view for that field. Is there any simple method by which I can fetch distinct city using the GetAllCustomer() procedure
Pankaj
|
|
|
|
|
I am trying to create 2 separate tables and print them in word, however I end up with two tables which are attached to each other..how do i differentiate between the two tables?or how do i seperate the two tables?is there a way in which i can insert a paragraph/break between the tables..can anyone please help?
1st of all im adding word files to listview.....with diff pname n date...i need to display in different tables...those files im adding/....
plzz see my code then u ll get idea...
private void btnsave_Click(object sender, EventArgs e)
{
List<string> DoctorNames = new List<string>();
List<string> dte = new List<string>();
List<string> pname = new List<string>();
foreach (ListViewItem litem in listView1.Items)
{
if (DoctorNames.Contains(litem.SubItems[4].Text) == false)
DoctorNames.Add(litem.SubItems[4].Text);
}
List<string> list1 = new List<string>();
List<string> list2 = new List<string>();
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
foreach (string name in DoctorNames)
{
Microsoft.Office.Interop.Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = name.ToString();
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Paragraph oPara2;
oPara2 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara2.Range.Text = "Date:" + dte.ToString();
oPara2.Range.Font.Bold = 1;
oPara2.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara2.Range.InsertParagraphAfter();
string query = "Select FileName,LineCount from tbl where PName='" + name + "'";
OleDbDataAdapter da = new OleDbDataAdapter(query, oldb);
DataSet ds = new DataSet();
int a = listView1.Items.Count + 1;
Microsoft.Office.Interop.Word.Table oTable;
Microsoft.Office.Interop.Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oTable = oDoc.Tables.Add(wrdRng, a, 3, ref oMissing, ref oMissing);
oTable.Range.ParagraphFormat.SpaceAfter = 6;
oTable.Cell(1, 1).Range.Text = "SNO";
oTable.Cell(1, 2).Range.Text = "FileName";
oTable.Cell(1, 3).Range.Text = "Total Count";
for (int r = 1; r < a; r++)
{
oTable.Cell(r + 1, 1).Range.Text = r.ToString();
oTable.Cell(r + 1, 2).Range.Text = listView1.Items[r - 1].SubItems[2].Text;
oTable.Cell(r + 1, 3).Range.Text = listView1.Items[r - 1].SubItems[7].Text;
oTable.Rows[r].Height = oWord.InchesToPoints(0);
}
oTable.Columns[1].Width = oWord.InchesToPoints(0); //Change width of columns 1 & 2
oTable.Columns[2].Width = oWord.InchesToPoints(0);
oTable.Columns[3].Width = oWord.InchesToPoints(0);
oTable.Rows[1].Range.Font.Bold = 1;
}
}
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">@nisha 2n wrote:</div>
for (int r = 1; r < a; r++)
{
oTable.Cell(r + 1, 1).Range.Text = r.ToString();
oTable.Cell(r + 1, 2).Range.Text = listView1.Items[r - 1].SubItems[2].Text;
oTable.Cell(r + 1, 3).Range.Text = listView1.Items[r - 1].SubItems[7].Text;
oTable.Rows[r].Height = oWord.InchesToPoints(0);
}
</blockquote>
I do not see where you are creating two different tables. Perhaps that code is being called else where?
Try:
if(ThisDocument.Tables.Count == 0)
oTable = ThisDoucument.Tables[0];
else
oTable = ThisDoucument.Tables.Add(wrdRng, a, 3, ref oMissing, ref oMissing);
oTable.Range.ParagraphFormat.SpaceAfter = 6;
oTable.Cell(1, 1).Range.Text = "SNO";
oTable.Cell(1, 2).Range.Text = "FileName";
oTable.Cell(1, 3).Range.Text = "Total Count";
for (int r = 1; r < a; r++)
{
oTable.Cell(r + 1, 1).Range.Text = r.ToString();
oTable.Cell(r + 1, 2).Range.Text = listView1.Items[r - 1].SubItems[2].Text;
oTable.Cell(r + 1, 3).Range.Text = listView1.Items[r - 1].SubItems[7].Text;
oTable.Rows[r].Height = oWord.InchesToPoints(0);
}
oTable.Columns[1].Width = oWord.InchesToPoints(0);
oTable.Columns[2].Width = oWord.InchesToPoints(0);
oTable.Columns[3].Width = oWord.InchesToPoints(0);
oTable.Rows[1].Range.Font.Bold = 1;
Just make sure you are indexing the correct table in the document.
~TheArch
|
|
|
|
|
hii,,,,,,
yah...im getting multiple tables.....
Actualy my proj is on linecount for Word files......
soo 1st im using list view for add some files .when im adding those
files i hav to select diff pysician name n date.........it ill stores
into data base((convert MS ACCESS data to MS Word))
n then whn im save that data ,then,,it ll b save in single word doc in
different tables..by selectd pysician name n date,..
....BUT iam getting repeating in one table lik...
Dr.Name:Dr.Jhon
Date:20/12/2009
Sno| FileName |Count
1 Hobbs.doc |36.31
2 Horn.doc |45.72
3 McMillan.doc |41.49
4 Smith.doc |10.72
Dr.Name:Dr.king
Date:22/12/2009
Sno |FileName |Count
1 Hobbs.doc |36.31
2 Horn.doc |45.72
3 McMillan.doc |41.49
4 Smith.doc |10.72
..........................................................................
this is actully i want 2 get....
Dr.Name:Dr.Jhon
Date:20/12/2009
Sno| FileName| Count
1 Hobbs.doc |36.31
2 Horn.doc| 45.72
Dr.Name:Dr.king
Date:22/12/2009
Sno| FileName |Count
1 McMillan.doc |41.49
2 Smith.doc| 10.72
|
|
|
|
|
Hi i have a requirement to extract a portion of image from tif/jpeg/bmp images using C# and paste that extracted image into an excelsheet.
Anyone is already done this before?
pl provide me some helpful info regarding this.
Advanced thanks for your help.
|
|
|
|
|
To extract a portion, you need to draw a portion of the original image into the source image, and use the Clipboard.SetImage method. From there, you simply have to let the user paste it into Excel, or do some interop and place it in yourself.
|
|
|
|
|
I am trying to write a small function in C# by passing this DNS name www.google.com
And the function should return the host IP , it is like querying DNS server!
I wrote the following program , but it seems there this Warning
Warning 1 'System.Net.Dns.Resolve(string)' is obsolete: 'Resolve is obsolete for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202' D:\CoDoNS\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 26 20 WindowsFormsApplication1
Using System;
Using Sytem.Net;
namespace BuilderExamples {
class BuilderIPAddress {
static void Main(string[] args) {
try {
IPHostEntry iphe = Dns.Resolve("www.google.com");
foreach (IPAddress addr in iphe.AddressList)
{
Console.WriteLine("AddressFamily: " + addr.AddressFamily.ToString());
Console.WriteLine("Address: " + addr.ToString());
}
}
catch (Exception e) {
Console.WriteLine("Error: " + e.ToString());
}
} } }
Why Dns.Resolve Method in C# is obsolete ?
is the a workaround to get that function done?
Thanks
|
|
|
|
|
Well, the warning message is already giving you the answer.
Use Dns.GetHostEntry: IPHostEntry iphe = Dns.GetHostEntry("www.google.com");
|
|
|
|
|
it works
but what is meant by "obsolete"?
Thanks my friend
|
|
|
|
|
"Obsolete" : "No longer in use"[^]
In practice, it means you should not use it for new projects; there is a better equivalent. If you do use it, be aware that future releases of the IDE may not support it, or may not support it fully. On your own head be it!
Would you specify a 80386 based computer for a new project? It is obsolete too.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I am working on creating a Datagridview Cell with a combobox which is having multiple columns in C#.I got the idea about multicoulumn combobox but i am having difficulty in implementing it to a datagridviewcombobox. Can anyone help me?
|
|
|
|
|
The canned DataGridViewComboBox does not support multi-column functionality; you'll need to implement a custom column to host your own combo box and set the proper options in order to allow it to be multi-column. Refer to the below article for information on creating custom DataGridView column classes, it's actually not that difficult to do; I've made a few custom columns using this information as the basis.
http://msdn.microsoft.com/en-us/library/7tas5c80.aspx[^]
Hope in one hand and poop in the other; see which fills up first. Hope and change were good slogans, now show us more than words.
|
|
|
|
|
how do i make such an application which is web based but multipoint sdk based also
please reply
thanks in advance
|
|
|
|
|
Please ask this question in Web Development forum. This isnot a right forum for ur question.
|
|
|
|
|
I have 3 gateways
Gateway
1: 192.168.0.1 >> DNS: 202.84.54.20
2: 192.168.0.2 >> DNS: 220.120.46.34
3: 192.168.0.3 >> DNS: 203.73.86.10
Any point of time my LAN TCP Settings will be using any one of the above configuration.
and i can check the internet connectivity on the current configuration but want to determine whether internet is available or not on any of the gateways apart from current one w/o configuring it.
My preference for the solution is : How can i check internet connectivity on different gateway & DNS Server Setting without having to change the LAN Settings
mayuresh
|
|
|
|
|
One way to do this is connect to any site from the certain interface.
An example:
static void Main(string[] args) {
Console.WriteLine(IsInternetUp("192.168.1.6"));
Console.WriteLine(IsInternetUp("127.0.0.1"));
}
private static bool IsInternetUp(string address) {
IPEndPoint localEp = new IPEndPoint(IPAddress.Parse(address), 0);
TcpClient client = new TcpClient(localEp);
try {
client.Connect("google.com", 80);
} catch (SocketException) {
return false;
} finally {
client.Close();
}
return true;
}
This will give:
True
False
Another way is to make a ping from a certain interface:
<br />
ping -S 192.168.1.6 google.com<br />
ping -S 127.0.0.1 google.com<br />
But I'm not sure whether it's possible to implement this using .NET Framework built-in classes.
Possibly this will help you: [^]
|
|
|
|
|
I am trying to insert a code block into the custom indicator wizard at Ninjatrader. They use C#. I've found a code block for what I want that produces eSignal's fractal index, I think they use javascript, and it inserts OK except for only 6 "expects ;" errors which I can fix. But at the end of this block, it gives an "expects statement" error. What ending statement goes there??? Will this revise the javascript version to Ninjascript OK? The last part of the code looks like this:
function verify() {
var b = false;
if (getBuildNumber() < 779) {
drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "error");
drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "upgrade");
return b;
} else {
b = true;
}
return b;
}
Ninjatrader's Ninjascript expects a closing statement right after the last "}" - What the heck is it? The whole code is here "http://forum.esignalcentral.com/showthread.php?threadid=22092
|
|
|
|
|
Hi guys.
I'm looking for a sample of ListView that contains some ListViewItems in XAML code.
I have been searching the web but I couldn't find any useful sample !
Could you guide me ?
Thanks.
|
|
|
|
|
|
Hi
sorry for bad subject!!
let me explain my project.
I create a Gate simulator ( AND - OR - XOR...) each gate is a user control.
user drag desired gates to page and then connect them to each other.
(for example the output of OR should connect to input of XOR gate)
I have no idea to how connect them to gather?!!
appreciate for your help.
N
o
N
ame
|
|
|
|
|
Hi,
1.
you need "wires" to interconnect input and output pins of your gates. So in your approach, why not create some "Wire" user controls (either arbitrary size and orientation, or a horizontal and a vertical having arbitrary length).
2.
I wouldn't use user controls at all for a drawing or CAD app; just a simple Panel onto which you add "electronic components", which would be instances of "Wire" and "SomeGate", both derived from "ElectronicComponent"; keep them in a List<ElectronicComponent>; give them a "Draw" method so they paint themselves on a given Graphics; use the Panel's mouse events to grab, move, resize them. Then add logic to discover which components are connected to which, so you get a circuit.
Suggestion: have a look at the source of some drawing app, maybe Paint.NET
|
|
|
|
|
thanks for your help and idea.
I will try your idea. but my experience in draw and graphics is zero
N
o
N
ame
|
|
|
|
|
you might have a look at my Sokoban article, it has some simple graphics; it does not however have click-and-drag.
If that does not help, maybe you should start with a simpler app first.
|
|
|
|
|
actually I don't want write this app, my teacher pressure on me to do this
I will take a look at your articles,
regards
N
o
N
ame
|
|
|
|
|
Hi all
i need helping of how to fragment a payload data at IP layer
packet fragmentation: devide an IP packet into pecies of sub packets.........
Regards
modified on Monday, December 28, 2009 2:29 AM
|
|
|
|