|
Inserting
------------------------------------------------------------
ms = new MemoryStream();
pbEmp.Image.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] data = new byte[ms.Length];
ms.Position = 0;
ms.Read(data, 0, Convert.ToInt32(ms.Length));
cmd.Parameters.AddWithValue("@Photo", data);
Retrieving
------------------------------------------------------------
byte[] data = (byte[])ds.Tables["tablename"].Rows[0][0];
ms = new MemoryStream(data);
picturebox.Image = Image.FromStream(ms);
|
|
|
|
|
i have 2 tables named : Customers, Orders which have relation together (Customers table is Parent table).
Now in my form, i have 2 DataGridView which display list of customers (in dataGridView1) and list of orders of selected customers (in dataGridView).
i wrote this code, but at runTime all orders display to dataGridView2 and when i change customer record, nothing happend!
here is my code :
TestDataSet ds = new TestDataSet();
private void Form2_Load(object sender, EventArgs e)
{
TestDataSetTableAdapters.CustomersTableAdapter cA = new TestDataSetTableAdapters.CustomersTableAdapter();
cA.FillCustomers(ds.Customers);
TestDataSetTableAdapters.OrdersTableAdapter oA = new TransactionalUpdate.TestDataSetTableAdapters.OrdersTableAdapter();
oA.FillOrders(ds.Orders);
dataGridView1.DataSource = ds.Customers.DefaultView;
dataGridView2.DataMember = ds.Orders.ParentRelations[0].RelationName;
dataGridView2.DataSource = ds.Orders.DefaultView;
}
can anybody help me to solve this problem ?
Thanks
|
|
|
|
|
hi I need to implement a formula translator in C#.
As an input I have a validated mathematical formula string such as "a+b*c+(c/d)".
I want to calculate this formula at runtime when parameters (a, b, c & d) are available.
As far as my application is concerned the formulas used will always be simple algebraic ones(as shown in the example)
Is there any existing facility in C# to do this?
OR any suggestions to implement this on our own?
|
|
|
|
|
There are, for instance, articles [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
can i get any links to those articles?
~~ Chase Excellence, Success will follow. ~~
|
|
|
|
|
I provided the links.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Someone out there must be able to help me...
I'm trying to find/design a way of automating my project's builds, publishing, versioning in VSS etc and I'd like to create an app/script that will obey my command and do in one easy button click, what would otherwise take copious amounts of time & attention.
The general idea is: Build a project/solution based on the .*proj files, publish the project with different config settings & install location depending on whether the app is going to QA, Pre-Prod or Production. I would also like to be able to have Source Safe's labelling done automatically.
So far, I have found that Microsoft's MSBuild Reference on MSDN is virtually useless ( ???), but I have been able to compile a project via the command line using it.
I found that Microsoft.Build.BuildEngine looked perfect for what I'm trying to acheive, however, using the following code, I can't get it to build the project:
Engine engine = new Engine();
Project project = new Project(engine);
project.Load(strProjFile);
project.Build();
The Build method on the Project keeps returning False - no error, nothing. (Before you ask, yes, the path to the project file is correct - the same file builds fine through VS2008 as well as MSBuild)
(Oh, and again, Great Job Microsoft on the crummy documentation)
If anyone has an idea of where I am going wrong, please, please, please! Let me know
|
|
|
|
|
Do you try to build a Continous Integration system?
I would suggest using CruiseControl.NET. We accomplished that on a check-in to VSS the projects are compiled, unit-tests will run, documentation and release notes generated and at least a msi-file will be created.
Regards
Sebastian
|
|
|
|
|
Hah! Victory
It appears that if you add logging, you find out what the problem is...
Engine engine = new Engine();
FileLogger logger = new FileLogger();
logger.Parameters = @"logfile=" + strlogFile;
engine.RegisterLogger(logger);
bool success = engine.BuildProjectFile(strProjectFile);
engine.UnregisterAllLoggers();
if (success)
MessageBox.Show("Build succeeded.");
else
MessageBox.Show(@"Build failed. View " + strLogFile + " for details");
Using the above code, I was able to view the log of the issue:
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets(64,7): error MSB4127: The "GetWinFXPath" task could not be instantiated from the assembly "PresentationBuildTasks, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
This issue in turn needs the following config file settings to be added:
<configuration>
<configSections>
<section name="msbuildToolsets" type="Microsoft.Build.BuildEngine.ToolsetConfigurationSection, Microsoft.Build.Engine, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<startup>
<supportedRuntime version="v2.0.50727" safemode="true"/>
<requiredRuntime version="v2.0.50727" safemode="true"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<!-- To define one or more new toolsets, add an 'msbuildToolsets' element in this file. -->
</configuration>
My project builds!
|
|
|
|
|
Has anyone else had issues similar to this?
If a row is selected in the DataGridView on a form the following event handling code correctly gets the index value of the row. However, the code to extract values from the row actually gets values from the next row. For example if the fourth row is selected, index has the correct value of 3 but the row values are from the fifth row. Decrementing the value returned from vDateDataGridView.CurrentRow.Index then referenced the third row! Decrementing and then incrementing the value again referenced the fifth row. If the index value is assigned from a constant (e.g. index = 3), the problem does not occur.
string str;
int index;
index = vDateDataGridView.CurrentRow.Index;// gives correct index
str = vDateDataGridView.Rows[index].Cells[0].Value.ToString();
str = vDateDataGridView[0, index].Value.ToString();
CurrentRow.Index supposedly returns an int, but this behaviour suggests rounding issues or similar. Recasting after using the CurrentRow.Index.ToString() function did not make any difference.
I have replicated this behaviour in a fresh form in the same project. The underlying data source is a View joining three tables. I will see if the same problem occurs with a single table datasource. Yes, it did.
Tony Horsham
|
|
|
|
|
does sound very strange. Have you tried using...
str = vDateDataGridView.SelectedRows[0].Cells[0].Value.ToString();
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Yes, literals work as expected.
This code to handle the CellClick event works as expected (currentRow and currentCol are declared as form properties).
private void vDateDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
currentRow = e.RowIndex;
currentCol = e.ColumnIndex;
string str;
str = vDateDataGridView[currentCol, currentRow].Value.ToString();
selectedCellLabel.Text = str;
}
But when the following line is executed in the other event handler, currentRow behaves as before!
str = vDateDataGridView[currentCol, currentRow].Value.ToString();
The workaround is to declare currentRow and currentCol as local variables in the CellClick event handler, declare the variables I want to extract from the DataGridView as form properties and get their values in the CellClick event handler.
modified on Tuesday, April 28, 2009 5:55 PM
|
|
|
|
|
I am novie to the Regular expression validatio. my req is a regular expression for currency with thousand seperatror which is decimal(14,3) ... checked the all availabe but no use.. pls help me to get it..(pls Note the regulare expression should restrict to decimal(14,3)
|
|
|
|
|
maybe you could put some examples of valid/invalid input so we can better understand your requirements
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
eg 1,12,000.00, 22,22,333.90 are valid but 12,33,333,444,444.900000(more than 11 preceding the point and more than 3 field afer the point)
|
|
|
|
|
what about...
string regexString = @"^[0-9,]{0,14}.[0-9]{0,3}$";
NOTE: i use 14 before . to allow for the 3 commas possible
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Thks for the post.. i did a basic test and seems it'w working ..thanks v much
|
|
|
|
|
want to sign my project assembly files with some private key and i'm using x509certificate class. I need this certification to be valid permenently, what should i do? we don't have access to edit the validation period in the certification directly, right?
any ideas????? Should i use another approach for my aim? What?
I appreciate any ideas...
Roshanak
|
|
|
|
|
I write ExecuteDataSet function;
public DataSet ExecuteDataSet(string commandText, string tableName, SqlParameter[] parameters)
{
try
{
OpenConnection();
using (SqlCommand command = new SqlCommand(commandText, this.connection))
{
command.Parameters.Add(AddParameter(command, parameters));
using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
{
DataSet ds = new DataSet();
dataAdapter.Fill(ds, tableName);
CloseConnection();
return ds;
}
}
}
catch (Exception ex)
{
//Exception Log
CloseConnection();
return null;
}
}
I wan to call AddParameter() fuction in the using block. Bu I get error.
private SqlParameterCollection AddParameter(SqlCommand command, SqlParameter[] parameters)
{
foreach (SqlParameter param in parameters)
{
command.Parameters.Add(new SqlParameter(param.ParameterName, param.Value));
}
return command.Parameters;
}
How can I do?
AddParameter() using in a lot of function. If I write foreach loop in the using block so code is repated a lot.
|
|
|
|
|
What kind of error do you get? Writing down the error message will help a lot.
|
|
|
|
|
Hi, I'm pretty new to programing and drawing is something I've only touched on
I need to get the program to draw a shape (done that) that's as large as the form is (minus some padding) and re sizes as the form size is changed.
I know about using *Whatever* = ((width > height) ? height : Width); but I don't know where to put it and I know about this.height and this.width but don't know where to put that.
So in a nutshell I need help with getting my shape to fill up the maximum possible room in the form and resizing as the form size is changed.
Thanks in advance for any help
P.S. I know this is a very rudimentary question for many (if not all) of you out there so please don't scoff at me
|
|
|
|
|
If you are drawing directly onto the surface of the Form you need to put your code in the Paint event handler of the Form .
Just in case you don't know how to do that. Make sure your Form is selected in the designer, then in the properties window, click the events button (at the top, lightening bolt), then double-click on the Paint item. A handler stub is created in the editor, put your code there.
private void MyForm_Paint(object sender, PaintEventArgs e)
{
}
By putting the code there, it guarantees that your code gets executed every time the Form is drawn, such as when it is resized.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Johnny, .
You can to use the resize event of the form , on resize event resize shape , hope you would be able to find event , events can be found using property window , there is small yellow colored , lighting shape button , it will show all event related to the selected object (in our case form , as we have kept it selected) , there You need to find resize and double click on to white space (cell) next to resize , designer will take you to event handler , where you should place your code .
Hope i have not made it more confusing , let me know if you need more information
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
I'd recommend not doing this directly on the form, but deriving a new control from Panel. This control you can place on your form with docking set to fill and it will resize. This way, you gain some portability in your control (for use on other forms). You can even add properties to help define the shape etc.
As far as the drawing goes, there are two handlers you're interested in OnPaint and OnResize. You can hook events for these, or if you do go down the derived control route just override them as protected overrides.
The Resize will just let you know when the control changes size - don't attempt to draw in this. I doubt you even need this really, as you've always got access to the Width and Height in the Paint method. (Actually, you may want to Invalidate() the whole control as the OnPaint handler will clip to just new areas that weren't there prior to the resize - if you need the whole shape to resize you will need to do this).
All drawing should always be done in the OnPaint method. The Width and Height tell you the dimensions. If ever you want to redraw something in Windows, Invalidate() the area and get the OnPaint method to do the drawing.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for the help guys (and 4 not flaming )
I already knew about the resize and paint events and have handled them correctly (or at least i think i have)
what i specifically need help with is getting the shapes to appear with a button click (multiple shapes each on a separate button) and the resizing of the shape as the form is resized
just a note
in the resize event i have the code
this.refresh();
is that all that goes in that section or is that where i put my code to resize the shape as well?
thanks again
|
|
|
|
|