|
I have a datatable named EmployeeDT. I am using hastable to store data. I want to to take an employeeID of EmployeeName from data table When i select Employee name in the combobox and add to HashTable.
I am binding data to combobox using this method
foreach(DataRow drow in EmployeeDT.Rows)
{
cboemployee1.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
cboemployee2.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
cboemployee3.Items.Add(drow["Name"].ToString().Replace("\"","\'"));
}
From this code how can i add key to the hash table...
|
|
|
|
|
Hashtable.Add(key, value)
Paul
|
|
|
|
|
No. Write it yourself. This is the best way to find solutions to problems, rather than relying on others.
Have you even read the .NET framework documentation? It shows you how to do it in there.
Paul
|
|
|
|
|
Who were you replying to?
God Bless,
Jason
I am not perfect but I try to be better than those before me.
So those who come after me will be better than I am.
|
|
|
|
|
I got the following reply from the OP
Can u write code according to my problem
I objected (reasonably) to having to do his work for him.
For some reason, his post didn't appear in the message thread...
Paul
|
|
|
|
|
I am currently working with a .Net web application. I have to create several complicated excel reports using that web application. I have two doubts
First Question:
Can I use all the excel functions with .Net ?
Do you have any good samples ?
Second Question:
This is not a windows application, this is a web server. Can I generate excel report by using .Net web application?
Thanks!
jayasshc
|
|
|
|
|
csecharithjayasshc wrote: First Question:
Can I use all the excel functions with .Net ?
Do you have any good samples ?
Do you need to include functions in your Excel spreadsheet? Or do you just need to output a set of literal values to it? If you just need to output data to your spreadsheet you should look at using the ODBC/Jet driver. Google will provide you with plenty of samples. If you need to create functions for particular cells, then you will need to use the Excel automation library. Again, Google should be your starting point.
csecharithjayasshc wrote: Second Question:
This is not a windows application, this is a web server. Can I generate excel report by using .Net web application?
Yes you can, but of the two options I mentioned above I would only recommend using the ODBC/Jet solution from a web application. Excel has a single-threaded architecture, so the automation library is not suited for use within a server application.
Regards
Paul
|
|
|
|
|
Dear Paul,
Thank you very much for the reply.
I just noticed another more important fact. I'll receive all the required data through a stored procedure. So I don't want to use excel functions, I can calculate everything in C# and post the calculated value on the cell.
So "Excel automation library" would be suitable for that, isn't it?
Thanks Again!
|
|
|
|
|
Yes, but you're still better off using the ODBC/Jet driver rather than Excel automation for the reasons I mentioned in my previous post. This is what I recently used when creating a data export facility for an ASP.NET web app.
Paul
|
|
|
|
|
Hi,
ok, is ODBC/Jet driver functionality depends on the excel version (2003 or 2007)?
Thanks!
|
|
|
|
|
No. You don't need Excel installed on the server, only the driver.
Paul
|
|
|
|
|
Hi Paul,
Could you please provide me a good C# example for odbc/jet driver thing?
I tried on the internet but still I couldn't find a proper one. I could find several nice article for "Excel Automation Library".
Thanks for your kind help!
Good Luck!!!
jayasshc
|
|
|
|
|
Try something like this:
string dataFile = "<path to your excel file>";
File.SetAttributes(dataFile, FileAttributes.Normal);
System.Data.OleDb.OleDbConnection tempExcelConnection = new System.Data.OleDb.OleDbConnection();
tempExcelConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;";
tempExcelConnection.ConnectionString += "Data Source=" + dataFile + ";";
tempExcelConnection.ConnectionString += @"Extended Properties=""Excel 8.0;HDR=Yes;"";";
System.Data.OleDb.OleDbCommand tempExcelCommand = new System.Data.OleDb.OleDbCommand();
tempExcelCommand.Connection = tempExcelConnection;
System.Data.SqlClient.SqlDataReader dr = null;
tempExcelCommand.Connection.Open();
if (dr.HasRows)
{
while(dr.Read())
{
tempExcelCommand.CommandText = String.Format("INSERT INTO [mynamedrange] VALUES ({0}, {1}, {2}, {3}, {4})", dr[0], dr[1], dr[2], dr[3], dr[4]);
tempExcelCommand.ExecuteNonQuery();
}
}
dr.Close();
tempExcelCommand.Connection.Close();
Regards
Paul
|
|
|
|
|
This article shows you another approach: http://www.bbv.ch/pdf_files/system_event/2005_XMLto%20Excel.pdf
XSLT is used to create Excel files.
The advantage is that you do not need Excel itself to create the files.
The disadvantage is that you have a Excel-xml file in the end. If you need to have an xls then you still have to use Excel to transform the xml to a xls file. But this is mus easier then program all data into Excel with interop.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
|
Hi,
if you are looking for a solution for a large project, you should evaluate the libraries offered by aspose http://www.aspose.com[^]. I started a project using COM/INTEROP to create an interface to the office world. Then it was necessary to support the generation of word documents on a server without having any MS office application installed. We decided to use aspose. Finally we were able to improve our applications noticeably.
Erik
|
|
|
|
|
i want get now month from system. how to get it.
thank you
|
|
|
|
|
hi
int month = DateTime.Now.Month;
regards
|
|
|
|
|
Can anyone tell me how to search a particular record from the MS Access database using C#. I want to use a combobox on which primary key of the table will be there and clicking on any particular primary key value, all the records related to that primary key value should be displayed in respective text boxes.
Help appriciated...
Thanks
Imran
|
|
|
|
|
Can you clarify a little more what you need to do?
Do you need to search one table for a PK or the entire DB?
ImranTech wrote: all the records related to that primary key value
Normally a PK is unique within the table.
God Bless,
Jason
I am not perfect but I try to be better than those before me.
So those who come after me will be better than I am.
|
|
|
|
|
I have come up with an authentication scheme that I wanted to run past everyone to see if you all agree with my logic. Here is the process:
1) The clients windows login credentials are automatically passed (manual option also provided) with the webservice call using:
WebService.Credentials = System.Net.CredentialCache.DefaultCredentials
2) The web.config is set to impersonate the user.
3) At this point I thought I could assume that the client is who they say they are since the user was able to log in to IIS. My plan is to use the username and SID to retrieve the information for that user as opposed to the traditional username and password scenario.
4) If the user's SID is ever out of sync I will provide the admin a sync option. Basically the same option I would have given them when they set up the user.
I guess I am worried about two things. Can I rely on these SID's as long as the user is not recreated in the domain and hopefully I can store the SID's in a database. I am not sure how "variable" in length these SID's can be. If I stored it in a character field at 255 will I be safe?
|
|
|
|
|
Hey all,
I am trying to load and parse a MIDI file in C#. So far, I have been able to read the header and make it to the first track. However, I am now confused. Some values in the file are kept as a variable length format (link to the page I am looking at: MIDI File Format[^]), and I am not sure how to manipulate this. Basically, it shifts bits around like so: C8 (11001000) becomes 8148 (10000001 01001000). The top bit is used to signal that another 7 bits of information follow. So... I guess I need to know how to move the bits back into a format that I can use. Is there a way to handle individual bits in C#?
|
|
|
|
|
|
Thanks a bunch for the reply. I tried using the first link, but got confused. The last link seems to be very helpful, almost exactly what I need. Thanks again 
|
|
|
|
|
I have an application that logs data based on messages sent to it from another app. It works great.
Now I want to hide it from the taskbar and live in the system tray (Notify Icon area).
When I call "ShowInTaskbar = false;" for my mainwindow, it stops recieving the messages.
I am registering the message in question and sending it to my app with a HWND_BROADCAST.
Any Ideas?
|
|
|
|