|
Sorry I know I am late to the thread, but I was just starting to look into document automation related topics on the server side and had some additions to make:
If we are talking about Word 2003 or 2007 documents and working with cached data (from a data source), the ServerDocument class is worth investigating (doesn't require Office on the server):
Accessing Data in Documents on the Server[^]. The how-tos and walkthroughs here all refer to workbooks but I think it applies to Word also.
If we are talking about Office 2007 (or later), then the Open XML format of documents comes into play. Check out the Open XML Format SDK 2.0[^] for more information. Here is an example of how to change the text in a table for a document: http://msdn.microsoft.com/en-us/library/cc850835(office.14).aspx[^].
|
|
|
|
|
Hi All,,
I want to get a Max value from a table and increment it by 1,, such as
if the max value is 1/50, It will be 2/50, but the problem how to get it from a db.
thanks all,,
|
|
|
|
|
You can use the SQL keyword MAX
SELECT MAX(ColumnName) AS ExpressionName
FROM TableName
Simon
|
|
|
|
|
but it is a string and when get the max return the wrong max;;
I have a 2 value in a databas
9/50
10/50
when get the max return 9/50, but it is a wrong max,,,
I want way to return 10/50 ,
|
|
|
|
|
Ahh. Well that's because as a string "9/50" comes after "10/50" because when you interpret it as a string, "9" is higher than "1".
I don't think there is an easy way of doing this in SQL.
Personally, I think your data type is wrong. If it's a numeric value you should be using some form of numeric data type, not a string.
If you can't change the data type, then it could be rather tricky. You would have to write a function that first split the string at the '/' sign and extracted the first half (This could be done with CHARINDEX[^] and SUBSTRING[^]. Possibly something like this: SUBSTRING(ColumnName, 0, CHARINDEX('/', ColumnName)) , then converted the string to a number (Possibly using CAST or CONVERT[^]). Then you could return the MAX value of this function.
SELECT MAX(CAST(SUBSTRING(ColumnName, 0, CHARINDEX('/', ColumnName)) AS Integer)) AS ExpressionName
FROM TableName
It's not quick though. I tested it on a table with only 10 rows in it, and it's quite slow. If you've got any significant amount of data to process it will take a long time.
Consider adding an extra Integer column to the table to store just the numeric component. This can then be pre set when the row is created or changed, so when you need to read the data you don't have to calculate it every time.
Simon
|
|
|
|
|
If you could, I'd suggest updating your existing data to make it all two-digits (or even three). For example:
UPDATE YourTable
SET YourField = '0'+YourField
WHERE LENGTH(YourField) = 4; Of course, this wouldn't work if you have single-digit numbers after the slash. In that case, you'll need to modify the condition of the update (and you'll probably want to update the numbers after the slash too).
Once done, your MAX statement will give you correct output.
By the way, such questions are more suitable to the "SQL and Database" message board.
My LinkedIn Profile
|
|
|
|
|
hi all,,,
I want to Know what is the last row inserted into a table in a database.
I use "select last_insertd_row from last_insrted_rows where table_nam=:t_name"
but i have a problem,, please help me.
thanks all
|
|
|
|
|
|
Hi ...
Usually you mark the records in a table with an incremented sequence field or a time stamp field(including hh:mm:ss) this way you can easly get the last inserted record ...
Hope that helped ...
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Hi,
Can i insert DataGridView in other DataGridView?
|
|
|
|
|
Yes, you can. Try it.
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
I need to do sth when the scrollbar in a listview is moved.
but I can not find out which event is activated when the scrollbar in the listview is moved.
can anyone give one idea for it?
thanks!
|
|
|
|
|
There isn't one unfortunately.
You could probably do what you want by overriding the window procedure and checking for the WM_VSCROLL[^] message.
Something like this:
public class MyListView : ListView
{
public event EventHandler Scrolled;
private int WM_VSCROLL = 0x115;
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_VSCROLL)
{
OnScrolled();
}
Debug.WriteLine(m);
base.WndProc(ref m);
}
private void OnScrolled()
{
EventHandler localEvent = Scrolled;
if (localEvent != null)
{
localEvent(this, EventArgs.Empty);
}
}
}
Simon
|
|
|
|
|
i need inject a plug to a project
yes that's realy a diffcult problem .i can't get a way to solv it .
i need you point out the key;
for example i want instantiation a object A ,that's object turn to a button on the Main (UI); So how i can do it ?
|
|
|
|
|
Hi,
I have to insert a logo in the excel file which is created using CreateText() method of file stream. After writing XML data in the file, I open the excel to insert a logo at the end. It is opening the excel and pasting the logo perfectly. But the problem is it is not saved properly. I have given my code below.
Excel.Application excelApplication = null;
Excel._Workbook workbook;
excelApplication = new Excel.ApplicationClass();
string fname = "D:\\datapointlogo.bmp";
object missing = System.Reflection.Missing.Value;
excelApplication.Visible = true;
excelApplication.UserControl = true;
workbook = excelApplication.Workbooks.Open(fileName, missing, missing, 5 , missing, missing
, missing, missing, missing, missing, missing, missing, missing, missing, missing);
Excel.Worksheet ThisSheet = (Excel.Worksheet)workbook.Sheets[1];
Excel.Range oRange = (Excel.Range)ThisSheet.Cells[35, 1];
Image oImage = Image.FromFile(fname);
oRange.set_Item(35, 1, oImage);
System.Windows.Forms.Clipboard.SetDataObject(oImage, true);
ThisSheet.Paste(oRange, fname);
workbook.Save();
After opening the excel file, I noticed that, File format for this excel is XMLSpreadsheet. I tried to manually change the file format in the Save As dialog and it worked fine.
Also, Please note that, I don't want to use the following line though it works fine.
workbook.SaveAs(fileName, Excel.XlFileFormat.xlExcel8,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
Excel.XlSaveAsAccessMode.xlNoChange, System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value);
I have to change the file format without using SaveAs method. Please help me.
Thanks,
S.Sriram.
modified on Monday, November 17, 2008 4:02 AM
|
|
|
|
|
I'd like to use that line in my in my app, however EXcel give an exception if I specify a fileformat other then missing.
Happy programming!!
|
|
|
|
|
For opening a file, you don't need a file format. So you dont have to give a value. But the catch is this method does not allow nulls. Hence the work around is create a missing variable and send it as parameter.
Or just give this System.Reflection.Missing.Value and try.
|
|
|
|
|
I have seen clr type used instead of c# type.for eg:-
int n1 = 6;
Single n2 = 14.3;
double n3;
So my question is using clr type always ,does improve speed ,saves time?Then why do we use c# types?May I know the advantages/disadvantages if any for using clr type in lieu of c# type?
|
|
|
|
|
There is no difference in performance between using the C# aliases or the CLR types, as they are not separate types. The int keyword for example is an alias for the System.Int32 type, so when you specify int , you are actually using the CLR type.
With a few rare exceptions there is absolutely no difference which you use. One of the exceptions are when you specify the underlying type for an enum:
enum test1 : int { Hello, There }
enum test2 : System.Int32 { Hello, There }
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi there
I am developing a windows application that will store passwords , credit card number and other sensitive information on the computer. Definetilely it will be stored in the file.
There are algorithms in System.Security.Cryptography TripleDes,RSACryptoServiceProvider etc etc.
Encrypting the file using above algorithms will require
private key(in case of asymmetric encryption) or
secret key and Intialization Vector(In case of symmetric encryption)
I have encrypted the data using the above key and is working fine.Now the challenge is where to store the Private Key so that i can retrive that key later to decrpyt the data and show to the user.
Please guide any reading material or code will be of help
Thanks
THE SK(Sandeep Kalra)
I am the One
|
|
|
|
|
Use Hashing algorithm for this purpose, because Hashing Algorithms are one way and no need to decrypt.
|
|
|
|
|
Sandeep Kalra wrote: Now the challenge is where to store the Private Key so that i can retrive that key later to decrpyt the data and show to the user.
You can probably encrypt the private key with something known as a master key. And then when needed, you can decrypt the key with the master key. There may be better techniques, but this is one i heard of.
EDIT: A master key can be a simple password (which is to be stored in your brain )
-------------------------------------------
It's code that drives you - Shyam
|
|
|
|
|
hi all,
I have static class where is a CompileRooms() method . Which is as :
public static void CompileRooms()
{
try
{
frmTimetablePopup objfrmTimetablePopup = (frmTimetablePopup)Application.OpenForms["frmTimetablePopup"];
DataGridView grd = new DataGridView();
grd.Location = new Point(310, 200);
grd.Size = new System.Drawing.Size(300, 200);
DataGridViewTextBoxColumn grdCol = new DataGridViewTextBoxColumn();
grdCol.HeaderText = "Days";
grdCol.Name = "Col1";
grdCol.Width = 50;
grdCol.DefaultCellStyle.BackColor = Color.CornflowerBlue;
grd.Columns.Add(grdCol);
objfrmTimetablePopup.Controls.Add(grd);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
but an error occur :"Object reference not set to an instance of an object."
problems is here ->objfrmTimetablePopup.Controls.Add(grd);
|
|
|
|
|
Hi zeeShan anSari,
when create object you have to use new key word.
like :
frmTimetablePopup objfrmTimetablePopup = new (frmTimetablePopup)Application.OpenForms["frmTimetablePopup"];
Check it out.
Pavan Pareta
|
|
|
|
|
frmTimetablePopup objfrmTimetablePopup = new (frmTimetablePopup)Application.OpenForms["frmTimetablePopup"]; this code also create syntax error
|
|
|
|
|