|
public void ExeQueryCmdArray(NewDBClass.DbName dbName, String[] sQuery)
{
this.dbNameCache = dbName;
this.DbInstance(dbName);
OleDbCommand cmdCommon1 ;
OleDbCommand cmdCommon2 ;
OleDbCommand cmdCommon3 ;
try
{
this.conOleDb.Open();
this.transOleDb = this.conOleDb.BeginTransaction();
switch (sQuery.Length)
{
case 2:
cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb);
cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb);
cmdCommon1.ExecuteNonQuery();
cmdCommon2.ExecuteNonQuery();
break;
case 3:
cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb);
cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb);
cmdCommon3 = new OleDbCommand(sQuery[2],conOleDb,transOleDb);
cmdCommon1.ExecuteNonQuery();
cmdCommon2.ExecuteNonQuery();
cmdCommon3.ExecuteNonQuery();
break;
}
this.transOleDb.Commit();
}
catch(System.Data.OleDb.OleDbException oe)
{
ExceptionClass.PrintException(oe.Message);
this.transOleDb.Rollback();
}
catch(System.Exception e)
{
ExceptionClass.PrintException(e.Message);
this.transOleDb.Rollback();
}
finally
{
this.conOleDb.Close();
}
}
I use Access Database, and I want to execute various Insert and Update Query strings.
As you know, That code is very annoying me. So, I'd like to change using [for Loop].
But, I don't know How To...
Is there anyone can help me..
Thanks!!
|
|
|
|
|
bania wrote:
switch (sQuery.Length) { case 2: cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb); cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb); cmdCommon1.ExecuteNonQuery(); cmdCommon2.ExecuteNonQuery(); break; case 3: cmdCommon1 = new OleDbCommand(sQuery[0],conOleDb,transOleDb); cmdCommon2 = new OleDbCommand(sQuery[1],conOleDb,transOleDb); cmdCommon3 = new OleDbCommand(sQuery[2],conOleDb,transOleDb); cmdCommon1.ExecuteNonQuery(); cmdCommon2.ExecuteNonQuery(); cmdCommon3.ExecuteNonQuery(); break; }
Replace with:
foreach (string q in sQuery)
{
new OleDbCommand (q, conOleDb,transOleDb).ExecuteNonQuery();
}
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I made it!!
Thank you...
|
|
|
|
|
Hi,
does Datagrid's Row has a tag property ? like control (Label/text) has a Tag (objecT) property which can store any object associate with it. so the same way I need to store an object with
each and every row of the datagrid ?
how do i do that?
Paresh
|
|
|
|
|
I was reading Joel Neubeck's article on watermarking (http://www.codeproject.com/csharp/Watermark.asp) and found it very interesting and helpful.
But I was left with the question, is there a method available that enables the drawing of text diagonally on an image, or even rotated 90 degrees for a vertical effect (such as vertically drawn up the right hand side of the graphic).
Any info would be great!
Thanks.
Bill Koch
|
|
|
|
|
an idea,
the best idea would be create a image in memory ,
get the graphics handle from it. write a text you want.
write to image.
now on picture box set that image and you can rotate that image.
the another option would be
1) get the graphics handle g
2) write a drawstring say letter 'a'
3) now u need the rotation algorithm to do that.
Paresh
|
|
|
|
|
wkoch wrote:
But I was left with the question, is there a method available that enables the drawing of text diagonally on an image, or even rotated 90 degrees for a vertical effect (such as vertically drawn up the right hand side of the graphic).
The Transform property on the Graphics object should let you rotate, translate, or scale all drawing done using that Graphics object by assigning the proper Matrix to it.
James
"It is self repeating, of unknown pattern"
Data - Star Trek: The Next Generation
|
|
|
|
|
Thanks for the tip. That worked out great!
I adapted it to VB, but basically I had to add the following lines:
Dim myMatrix As New Matrix()
Dim rotatePoint As New PointF(xPos, yPos)
'Rotate the matrix "Me.Angle" degrees
myMatrix.RotateAt(Me.Angle, rotatePoint, MatrixOrder.Append)
' Draw the rectangle to the screen again after applying the
' transform.
grPhoto.Transform = myMatrix
'draw the string of text onto the graphics object.
grPhoto.DrawString(mWMString, crFont, semiTransBrush2, rotatePoint, StrFormat) 'string of text
'font
'Brush
'Position
''prep the image for saving.
imgPhoto = bmPhoto
|
|
|
|
|
Hi,
I'm trying to direct acces to MDDraw surface memory.
I'm using Lock() method but I don't understand it.
I was doing same thing in C++ and DX7..
Unmanaged Lock() returns pointer to memory and informations about format, but managed Lock() returns 2-dimensional array of byte (width and height of this array is same as size of the surface, but this is not enough for saving color in 32bit format).
Following code does nothing:
Byte[,] btData=surfaceBack.Lock(LockFlags.SurfaceMemoryPointer|LockFlags.Wait);
for(int x=0; x<100; x++)
{
for (int y=0; y<100; y++)
{
btData[x,y]=(byte)x;
}
}
srfBack.Unlock(btData);
Thank you for help.
[edit] MSDN : Surface.Lock() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_m/directx/ref/ns/microsoft.directx.directdraw/c/surface/m/lock0.asp[^][/edit]
i'm only pointer to myself
|
|
|
|
|
While building an icon editor to get the feel for graphics handling I came upon a problem.
I have a panel that is has been grided out with lines, 32x32, which as you draw updates a Bitmap which is 64x64. When I go to save the icon I I convert it down to a 32x32 Bitmap and the attempt to save it.
If I take the saved file and load it into an image editor the image comes out fine. However, when I try and reload the Icon via new Icon(FileName) I get this Exception.
An unhandled exception of type 'System.ArgumentException' occurred in system.drawing.dll<br />
<br />
Additional information: The argument 'picture' must be a picture that can be used as a Icon.<br />
When looking at the file in the folder view it shows the Windows "Unassociatated Icon".
If I save the Image in Bitmap format it shows the Image next to the file, but
it still throws the Exception when reloading. Also if I build a release it throughs an error on the icon that says
Error generating Win32 resource: Error reading icon 'E:\Programming\Icons Plus\Icons Plus\bin\Debug\myIcon2.ico' -- The data is invalid. <br />
Any ideas on how to get the image saved properly so that it can be used as an Icon.
|
|
|
|
|
it drawing.dll won't accept if its 8 bit image.
make it 16 bit or higher.
Paresh
|
|
|
|
|
Thanks: Worked Like A Charm
|
|
|
|
|
Which PixelFormat should be used. As long as I set it to put out a BMP the Icon "works". That is unless I set it to the application Icon.
I need to set the ImageFormat to .Icon. When I do that I get a "Unassoicated Icon" instead.
|
|
|
|
|
Hi!
I wanted to make my own custom user interface for my windows application, so I worked with a border-less form (FormBorderStyle = None) to hide the Title Bar, implemented my Interface with Bitmaps, Panels and Pictureboxes etc., and then re-implemented all standard windows-functions so that the user could maximize, minimize, rescale... his window like he was able to do in a normal windows applications.
But then I noticed that, when you work with a border-less form, the System Menu that normally appears when the user right-clicks on the program in the task bar, has disappeared! Is there a way in C# to do make the System Menu appear with a borderless form when a user right-clicks? I thried to search a solution in the Win32 API but didn't found one...
Thank you very much in advance!
Peter Dedene
student KULeuven - Belgium
|
|
|
|
|
When program enters public method MyClass.Flush 'document' has 5 childnodes.
After program opens file.xml variable document has 0 childs - what is wrong ???
private static XmlDocument document;
....
public void Flush() {
XmlTextWriter writer = new XmlTextWriter("file.xml",System.Text.Encoding.UTF8);
writer.Formatting = Formatting.Indented;
document.WriteTo( writer );
writer.Flush();
writer.Close();
}
Thank you.
|
|
|
|
|
check the previous System.Text.Encoding.UTF8 encoding format.
have u checked preservewhitespace ?
Paresh
|
|
|
|
|
|
Hi.
I'm working on a software that needs to export data from one application to another.
Both applications are written in C# and change versions frequently, and exported data needs to be (to some degree) compatible.
Another application (written in unmanaged c++ without .net support) might require ways to easily import that data.
Since I'm relatively unexperienced C# developer I do not know how does .net serialization works, could it be easily used or should I develop custom data format?
Data is consisted of various type parts, some of them having large binary chunks. Base64 encoding is not acceptable, since additional size of ~34% is too high, so plain binary format with some type description (for purpose of versioning) is required.
So basicly my question is what data format do I get when I serialize .NET class (and what parts of object info is stored) with [Serializable] attribute, using BinaryFormatter or SoapFormatter, and how do I tweak it - and all that explained in few simple words
|
|
|
|
|
You will not be able to de-serrialize a managed code object from a non-managed application, as the target objects' structure must be absolutely identical to the serialized objects' structure.
Given your requirements, creating your own data format would be the way to go.
|
|
|
|
|
Not entirely true: the serializer's binder can be overridden to enable reading other versions of the data...
VictorV
|
|
|
|
|
Hi,
I'm trying to have to windows inside another ( tree view in the left side , and my own form in the right side), I've tried this code ( only to add my own window there... )
Form1 MainForm = new Form1();
HijaDrcha RightWindow = new HijaDrcha();
MainForm.Controls.Add(RightWindow);
Application.Run(MainForm);
This compiles fine, but when I try to run this, it gives me one exception , any clues about how can this work ? ( or did I miss some parameter in the form or ... ?).
Thanks in advance,
Braulio
|
|
|
|
|
Whats the exception? You might try using a splitter window as well.
R.Bischoff | C++
.NET, Kommst du mit?
|
|
|
|
|
Hi,
If I use an Splitter, the exception that I get is:
"Cannot Add a top level control to a control"
Is there some style that I can switch off ? ( how ?), or Window Forms are top level controls ?
Thanks in advance, greetings
Braulio
|
|
|
|
|
I don't think you can add a form to another form unless it's an MDI container (and I don't think that's what you're trying to do). The "inner" form should probably be a control rather than a form.
Paul
And you run and you run to catch up with the sun, but it's sinking Racing around to come up behind you again The sun is the same in a relative way, but you're older Shorter of breath, one day closer to death - Pink Floyd, Time
|
|
|
|
|
Can I model a control as a form ? In MFC it worked like, "I have two views ( edit the aspect with the resource editor), then use CSplitterWnd and add both views).
Sorry, but I'm new to this Windows Forms World...
Thanks
Braulio
|
|
|
|
|