|
But the thing is i dont have just two images, i have images coming from a folder and their nuumber can vary and need to be placed systematically on a panel and then i need to draw lines between them. Is it possible in the way you have told me, please let me know.
Thanks
Nitin
|
|
|
|
|
So instead of calling Graphics.DrawImage twice call it as many times as you need. It's no different conceptually than instantiating X number of PictureBox es, siting those in your container control, and loading images into them. The biggest differences between drawing the images yourself and using PictureBox controls is that PictureBox controls have more overhead (they're controls - not just an image) and aren't as flexible as drawing the images yourself. Like I said before, if you want your line to overlap the images you either need to use layered windows (not easy - requires that you P/Invoke a could of native methods, define constants from various Windows APIs headers, and a couple of structs that are defined natively) or draw it all on the same surface. It's really not that hard.
Again, read the documentation for the Graphics class which has a lot of examples for owner-drawing as well.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello Heath,
I have tried to implement what you told me to but when i scroll the panel i lose the images and the system becomes too slow. I am calling DisplayThumbnails1() on panel1_paint. Here is the code
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
namespace medappzDMS.folderList
{
///
/// Summary description for fmlinks.
///
public class fmlinks : System.Windows.Forms.Form
{
private CustomAutoScrollPanel.ScrollablePanel panel1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage thumbnails;
private System.Windows.Forms.TabPage actualsize;
private System.Windows.Forms.PictureBox[] pb;
private System.Windows.Forms.Label[] lbl;
//private System.ComponentModel.IContainer components;
//private System.Drawing.Image _image = null;
private int _margin = 50;
private bool m_MouseIsDown=false;
private bool m_IsDragDrop=true;
//private bool panelmousedown=false;
//private string[] arrfilename;
private string[] arrfileindex1;
private string[] arrfileindex2;
// private char[] charfileindex1;
private string[] filename;
private string[] filename1;
private string locallink=null;
private string linkfrom=null;
private int j=0;
private bool hascolor=false;
private System.Drawing.Image _image = null;
private string pbcolor;
private int x1=0,y1=0,x2=0,y2=0;
Rectangle SelectRect = new Rectangle();
Point ps=new Point();
private System.Windows.Forms.Label lblviewcurlinks;
private System.Windows.Forms.Label lblcurlinks;
Point pe=new Point();
private System.Windows.Forms.ToolTip toolTip1;
private System.ComponentModel.IContainer components;
private string startcoordinates=null;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.NumericUpDown numericUpDown5;
private System.Windows.Forms.NumericUpDown numericUpDown6;
private string endcoordinates=null;
//private Image[] newimage;
private int width=150;
private int height=120;
private bool imagedrawn=false;
private System.Drawing.Image Image
{
get { return _image; }
}
public fmlinks()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
string [] fileEntries = Directory.GetFiles(utils.imgfolderpath);
j=fileEntries.Length;
//arrfilename=new string[j];
arrfileindex1=new string[j];
arrfileindex2=new string[j];
//charfileindex1=new char[]{'#'};
filename=new string[j];
filename1=new string[j*3];
//newimage=new Image[j];
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(fmlinks));
this.tabControl1 = new System.Windows.Forms.TabControl();
this.thumbnails = new System.Windows.Forms.TabPage();
this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
this.lblviewcurlinks = new System.Windows.Forms.Label();
this.lblcurlinks = new System.Windows.Forms.Label();
this.panel1 = new CustomAutoScrollPanel.ScrollablePanel();
this.panel2 = new System.Windows.Forms.Panel();
this.actualsize = new System.Windows.Forms.TabPage();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.tabControl1.SuspendLayout();
this.thumbnails.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.thumbnails);
this.tabControl1.Controls.Add(this.actualsize);
this.tabControl1.Location = new System.Drawing.Point(8, 8);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(580, 520);
this.tabControl1.TabIndex = 0;
//
// thumbnails
//
this.thumbnails.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("thumbnails.BackgroundImage")));
this.thumbnails.Controls.Add(this.numericUpDown6);
this.thumbnails.Controls.Add(this.numericUpDown5);
this.thumbnails.Controls.Add(this.lblviewcurlinks);
this.thumbnails.Controls.Add(this.lblcurlinks);
this.thumbnails.Controls.Add(this.panel1);
this.thumbnails.Location = new System.Drawing.Point(4, 22);
this.thumbnails.Name = "thumbnails";
this.thumbnails.Size = new System.Drawing.Size(572, 494);
this.thumbnails.TabIndex = 0;
this.thumbnails.Text = "Thumbnails";
//
// numericUpDown6
//
this.numericUpDown6.Location = new System.Drawing.Point(352, 8);
this.numericUpDown6.Maximum = new System.Decimal(new int[] {
100000,
0,
0,
0});
this.numericUpDown6.Name = "numericUpDown6";
this.numericUpDown6.TabIndex = 4;
this.numericUpDown6.Visible = false;
this.numericUpDown6.ValueChanged += new System.EventHandler(this.numericUpDown6_ValueChanged);
//
// numericUpDown5
//
this.numericUpDown5.Location = new System.Drawing.Point(488, 8);
this.numericUpDown5.Maximum = new System.Decimal(new int[] {
100000,
0,
0,
0});
this.numericUpDown5.Name = "numericUpDown5";
this.numericUpDown5.TabIndex = 3;
this.numericUpDown5.Visible = false;
this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
//
// lblviewcurlinks
//
this.lblviewcurlinks.AutoSize = true;
this.lblviewcurlinks.Location = new System.Drawing.Point(192, 16);
this.lblviewcurlinks.Name = "lblviewcurlinks";
this.lblviewcurlinks.Size = new System.Drawing.Size(0, 16);
this.lblviewcurlinks.TabIndex = 2;
//
// lblcurlinks
//
this.lblcurlinks.Location = new System.Drawing.Point(48, 16);
this.lblcurlinks.Name = "lblcurlinks";
this.lblcurlinks.Size = new System.Drawing.Size(72, 23);
this.lblcurlinks.TabIndex = 1;
this.lblcurlinks.Text = "Current Link";
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.AutoScrollHorizontalMaximum = 100;
this.panel1.AutoScrollHorizontalMinimum = 0;
this.panel1.AutoScrollHPos = 0;
this.panel1.AutoScrollVerticalMaximum = 100;
this.panel1.AutoScrollVerticalMinimum = 0;
this.panel1.AutoScrollVPos = 0;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel1.Controls.Add(this.panel2);
this.panel1.EnableAutoScrollHorizontal = true;
this.panel1.EnableAutoScrollVertical = true;
this.panel1.Location = new System.Drawing.Point(8, 48);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(568, 440);
this.panel1.TabIndex = 0;
this.panel1.VisibleAutoScrollHorizontal = true;
this.panel1.VisibleAutoScrollVertical = true;
this.panel1.ScrollVertical += new System.Windows.Forms.ScrollEventHandler(this.panel1_ScrollVertical);
this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint_1);
this.panel1.ScrollHorizontal += new System.Windows.Forms.ScrollEventHandler(this.panel1_ScrollHorizontal);
this.panel1.ScrollMouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel1_ScrollMouseWheel);
//
// panel2
//
this.panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel2.BackgroundImage")));
this.panel2.Location = new System.Drawing.Point(24, 16);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(700, 750);
this.panel2.TabIndex = 0;
this.panel2.Click += new System.EventHandler(this.panel2_Click);
this.panel2.MouseUp += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseUp);
this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
this.panel2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseMove);
this.panel2.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// actualsize
//
this.actualsize.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("actualsize.BackgroundImage")));
this.actualsize.Location = new System.Drawing.Point(4, 22);
this.actualsize.Name = "actualsize";
this.actualsize.Size = new System.Drawing.Size(572, 494);
this.actualsize.TabIndex = 1;
this.actualsize.Text = "Actual Size";
//
// fmlinks
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(592, 542);
this.Controls.Add(this.tabControl1);
this.Name = "fmlinks";
this.Load += new System.EventHandler(this.fmlinks_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.fmlinks_Paint);
this.tabControl1.ResumeLayout(false);
this.thumbnails.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void fmlinks_Load(object sender, System.EventArgs e)
{
//DisplayThumbnails1();
}
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DisplayThumbnails1();
}
private void panel1_ScrollHorizontal(object sender, System.Windows.Forms.ScrollEventArgs e)
{
//this.label2.Text = "horizontal scroll :: type: " + e.Type.ToString();// + " :: pos: " + e.NewValue;
this.numericUpDown5.Value = e.NewValue;
// this.panel1.AutoScrollHPos =e.NewValue;
}
private void panel1_ScrollVertical(object sender, System.Windows.Forms.ScrollEventArgs e)
{
//this.label2.Text = "vertical scroll :: type: " + e.Type.ToString();
this.numericUpDown6.Value = e.NewValue;
//this.panel1.AutoScrollVPos = e.NewValue;
}
private void panel1_ScrollMouseWheel(object sender, System.Windows.Forms.MouseEventArgs e)
{
//this.label4.Text = e.Delta.ToString();
//this.numericUpDown6.Value = this.panel1.AutoScrollVPos;
//this.panel1.AutoScrollVPos = e.NewValue;
}
private void panel2_Click(object sender, System.EventArgs e)
{
this.panel1.Focus();
}
private void numericUpDown5_ValueChanged(object sender, System.EventArgs e)
{
this.panel1.AutoScrollHPos = System.Convert.ToInt32( this.numericUpDown5.Value );
}
private void numericUpDown6_ValueChanged(object sender, System.EventArgs e)
{
this.panel1.AutoScrollVPos = System.Convert.ToInt32( this.numericUpDown6.Value );
}
private void DisplayThumbnails1()
{
Panel thisform = (Panel)panel2 ;
Graphics g = thisform.CreateGraphics();
string [] fileEntries = Directory.GetFiles(utils.imgfolderpath);
int j=fileEntries.Length;
for(int i=0; i
|
|
|
|
|
There's several things wrong I can see by scanning this over:- Put
g.Dispose in a finally block, however... - DO NOT use
CreateGraphics with owner-drawing; use the PaintEventArgs.Graphics that is passed to you in your OnPaint override. This could be responsible for quite a bit of the performance problem. Use the right ControlStyles bits in call to Control.SetStyle in your constructor to send all paint messages to OnPaint and allow for double-buffering. Be sure to read the documentation for the ControlStyles enumeration so that you use the right flags. In order to enable double-buffering you need to specify three different enumeration members. These are mentioned in the documentation for said enumeration. - When painting your controls - don't redraw the whole thing. You only need to re-draw what is passed to you in the
PaintEventArgs.ClipRectangle . Depending on what you're drawing, the Graphics class members let you draw certain rectangles of an image only. If you redraw the entire image every time you will also notice performance pentalties, especially if transforms are applied to shrink the image, etc.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello Heath,
Thanks for all the help. I have implemented point 1 and 2 but i am not able to implement point 3. I am calling Displaythumbnails() on panel paint event, it redraws all the images again, how do i implement cliprectangle? The application becomes slow when i scroll the panel
Thanks
Nitin
|
|
|
|
|
Use the methods of the Rectangle struct (of which ClipRectangle is defined) to see if your images and lines (artifacts) lie within the clipping rectangle, then redraw them. Do not redraw artifacts that lie outside of the clipping rectangle.
If you can, only redraw portions of the artifacts that are within the clipping rectangle.
There's many articles here on CodeProject about drawing. I suggest you try searching for them by using the search textbox at the top of every page directly underneath the logo.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for all the help Heath. My previous problems are solved. Now i have a new one, its regarding Pen object. I am drawing lines of different colors based on a criteria. I have an If Else loop and when the panel paint event is called it selects the color specified in the else statement by default. Kinda overrides the color in the if statement. So all the lines turn out be blue. Here is the code:
foreach(Line l in Lines)
{
if(locallink!=null)
{
char charfileindex1='#';
int charfileindexlen1=locallink.Split(charfileindex1).Length;
string[] ss=new string[charfileindexlen1];
ss=locallink.Split(charfileindex1);
for(int i=0; i<charfileindexlen1; i++)
="" {
="" int="" index="ss[i].IndexOf(dragimage);
" if(checklinks(ss[i].tostring())=""> 0)
{
DrawAssocLine(l);
label4.Text="Red"+k.ToString();
k++;
}
else
{
DrawLine(l);
label5.Text="Blue"+m.ToString();
m++;
}
}
}
}
Region r = getRegionByLine(line,p);
thumbnailpanel.Invalidate(r);
thumbnailpanel.Update();
r.Dispose();
|
|
|
|
|
My Form is flickering like hell, maybe because I have a lot of components in it (treeview, textboxes, listboxes, toolbar, menu, statusbar), and i couldn't find any solution for this. Double Buffering with SetStyle didn't work.
What can I do to reduce the flickering?
|
|
|
|
|
ControlStyles.DoubleBuffer - which must be combined with ControlStyles.AllPaintingInWmPaint and ControlStyles.UserPaint as the documentation states - is only effective when drawing your own forms. It will not simply change how GDI+ renders controls.
If you're getting flickering from including controls from the BCL on your form (all of which - at least for those you mentioned - encapsulates the native Common Controls) then you're machine is most likely the problem (or you're taxing the CPU by some pretty hefty code in your form's OnResize override or Resize event handler).
Check to make sure your monitor's refresh rate is as high as the monitor will support. If you're system doesn't have a lot of memory I recommend getting more memory.
Without knowing more it's hard to say, though. Do you have a lot of code in either the override or event handler I mentioned above? Is there anything else going on when your resizing or moving the form around? Do you have 20 instances of VS.NET open?
Basically, you should not be seeing any flickering (within reason; a Pentium I or II would be bad with, say, XP). Those controls you mentioned are actually the native controls that are wrapped by Windows Forms (so that controls are consistent with the platform, unlike Java AWT or Swing - though controls native to the framework have their advantages, too). If you're not seeing flickering on any of your native applications (like Windows Explorer, for example) then something else is the problem.
If you are doing a lot of work in your application when the form moves around or is resized then consider doing that work in a separate thread (if possible) so that the form can be repainted. If you need to update the UI from another thread, be sure to update the UI (i.e., makes calls on it) in the thread on which it was created by using the Control.Invoke method.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I don't think that the problem is dependent from my machine. I have a Athlon 2200+ CPU and 500 Megabytes RAM and it also happens without having the CPU loaded.
And it flickers as much as it does on my 1.5Ghz Notebook.
And yes I have a OnResize Event but commented out it's content. (it flickers on both ways)
I'll try to create a new Project and copy all forms from my original program to see if my program causes that flickering.
Thanks for investing so much (writing-)time for this
|
|
|
|
|
TyronX wrote:
And yes I have a OnResize Event but commented out it's content.
There is no OnResize event. If you override OnResize you must either comment the entire definition of the method (including the method itself) or call base.OnResize , passing the parameters you were given. When you override a method you are being called in place of the base class's implementation. Often times the base class implements something in that handler, besides firing the event.
So, if you are overriding it call base.OnResize or comment out the whole thing. If you're handling the Resize event than this isn't a problem (only with cancelable events like those defined as CancelEventHandler can you cancel whatever implementation the base event handler allows, like setting a property or losing focus for things like input validation).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Oh. No, I meant the Resize Event. I wasn't sure wether both were the same
|
|
|
|
|
Hi Everybody,
If got a problem:
When I run my program I get an error:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
I tried a lot of other things but I still get this error.
Can anybody see what the problem is?
The code (of the class):
using System;
using System.Data;
using System.Data.OleDb;
namespace AISDBL
{
///
/// Summary description for Database.
///
public class Database
{
OleDbDataAdapter dataAdapter;
//SqlDataAdapter dataAdapter;
string connectionString;
public Database(string applicationPath)
{
connectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=./data/db.mdb;";
}
public DataSet getNieuws()
{
string SqlString = "select * from user";
DataSet dstResult= new DataSet();
dataAdapter = new OleDbDataAdapter(SqlString, connectionString);
dataAdapter.Fill(dstResult);
return dstResult;
}
}
}
Thanks
|
|
|
|
|
Robske wrote:
An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll
And what does the additional information of the exception say? The answer will be there, without it we cannot help you.
PS: You need to open the Connection, before calling Fill().
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
I Changed a few things but still the same error:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.OleDb.OleDbException: The component FROM contains a syntax error.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at AISDBL.Database.getNieuws() in d:\ontwikkelmap\visual studio projects\ais\aisdbl\database.cs:line 33
at AIS.FrmLogin.btnLogin_Click(Object sender, EventArgs e) in d:\ontwikkelmap\visual studio projects\ais\ais\load\frmlogin.cs:line 141
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
AIS
Assembly Version: 1.0.1818.29878
Win32 Version: 1.0.1818.29878
CodeBase: file:///D:/Ontwikkelmap/Visual%20studio%20projects/AIS/AIS/bin/Debug/AIS.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
AISDBL
Assembly Version: 1.0.1818.29877
Win32 Version: 1.0.1818.29877
CodeBase: file:///D:/Ontwikkelmap/Visual%20studio%20projects/AIS/AIS/bin/Debug/AISDBL.DLL
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitdebugging="true">
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
I dont understand because it's simple code
|
|
|
|
|
Robske wrote:
************** Exception Text **************
System.Data.OleDb.OleDbException: The component FROM contains a syntax error.
So there is your problem. Could be wrong table name or the one u chose mite be a system table and it doesnt resolve, etc etc.
top secret Download xacc-ide 0.0.3 now! See some screenshots
|
|
|
|
|
Jepz, ur right, it's the table name that causes the problem.
|
|
|
|
|
If you must use a table name (or field name) that is also a keyword for Access, try putting it in square brakets.
e.g: "Select * from [user]"
Why would anyone waste time arguing with an accountant about anything? Their sole function is to record what happenned, and any higher aspirations are mere delusions of grandeur. On the ladder of productive contributions they are the little rubber pads at the bottom that keep the thing from sliding out from under you. - Roger Wright
|
|
|
|
|
Ur right, that was the problem. user is a keyword!!
THANKS
|
|
|
|
|
Actually you don't. DataAdapter.Fill and DataAdapter.Update - or rather the default implementation of DbDataAdapter that extends DataAdapter and from which the other DataAdapter -derivatives directly derive) will open and close the connection if the connection was not open already.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I think that the message within the exception would help a little bit more.
So what you have to do is to put your method getNieuws in a try-catch:
<br />
public DataSet getNieuws()<br />
{<br />
try {<br />
string SqlString = "select * from user";<br />
DataSet dstResult= new DataSet();<br />
<br />
dataAdapter = new OleDbDataAdapter(SqlString, connectionString); <br />
dataAdapter.Fill(dstResult);<br />
<br />
return dstResult; <br />
} catch (OleDbException ex) {<br />
Console.WriteLine(ex.Message)<br />
return null;<br />
}<br />
}<br />
Then look at your console what the exception writes back...
I think that would help a bit more
Sebastian Martens
|
|
|
|
|
I Changed a few things but still the same error:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Data.OleDb.OleDbException: The component FROM contains a syntax error.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at AISDBL.Database.getNieuws() in d:\ontwikkelmap\visual studio projects\ais\aisdbl\database.cs:line 33
at AIS.FrmLogin.btnLogin_Click(Object sender, EventArgs e) in d:\ontwikkelmap\visual studio projects\ais\ais\load\frmlogin.cs:line 141
at System.Windows.Forms.Control.onclick(EventArgs e)
at System.Windows.Forms.Button.onclick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
AIS
Assembly Version: 1.0.1818.29878
Win32 Version: 1.0.1818.29878
CodeBase: file:///D:/Ontwikkelmap/Visual%20studio%20projects/AIS/AIS/bin/Debug/AIS.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
AISDBL
Assembly Version: 1.0.1818.29877
Win32 Version: 1.0.1818.29877
CodeBase: file:///D:/Ontwikkelmap/Visual%20studio%20projects/AIS/AIS/bin/Debug/AISDBL.DLL
----------------------------------------
System.Data
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
I dont understand because it's simple code
|
|
|
|
|
'user' is a keyword. To use it (or any other access keyword) as a table or field name in a query you must surround it with square brackets.
try "select * from [user]"
Why would anyone waste time arguing with an accountant about anything? Their sole function is to record what happenned, and any higher aspirations are mere delusions of grandeur. On the ladder of productive contributions they are the little rubber pads at the bottom that keep the thing from sliding out from under you. - Roger Wright
|
|
|
|
|
Hi all,
What is the mechanism for implementation of the "undo" and "redo"
functions in those applications, e.g. in a text editor ?
Are there any sample codes or reference in C# ?
Thanks
|
|
|
|
|
How you implement undo/redo is entirely dependant on the type of data you're working on.
For example, for a bitmap editor, an incredibly simple way (but somewhat naive) is to have two dynamic stacks - an undo stack and a redo stack.
Every time you change the bitmap, just place a copy of the image before the change onto the undo stack.
When the user selects to undo, push the current bitmap into the redo stack, and pop the top image off the undo stack.
Now if you're smart, you can store just the change in the stack rather than the whole image, which will use less resources
One thing to note is that undo/redo is far easier to implement if it's done from the start - trying to shoehorn undo/redo functionality into an existing application can be incredibly tricky
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|