|
Hi everyone
I have a problem when i try to read from database. the exception message says
Unspecified error: E_FAL_(0x80004005)
any one can help me?
The code is included in this file
the source code is also here
-----------------------------------------
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace blood
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Button button1;
private System.Data.OleDb.OleDbCommand oleDbCommand1;
private System.Data.OleDb.OleDbConnection oleDbConnection1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// 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()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.oleDbCommand1 = new System.Data.OleDb.OleDbCommand();
this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.label2});
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(424, 64);
this.panel1.TabIndex = 0;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(225, 24);
this.label2.Name = "label2";
this.label2.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.label2.Size = new System.Drawing.Size(174, 13);
this.label2.TabIndex = 1;
this.label2.Text = "ÇáÑÌÇÁ ßÊÇÈÉ ßáãÉ ÇÓã ÇáãÓÊÎÏã æ ßáãÉ ÇáãÑæÑ";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(16, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(48, 48);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(283, 105);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(54, 13);
this.label3.TabIndex = 1;
this.label3.Text = "ÇÓã ÇáãÓÊÎÏã";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(289, 145);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(48, 13);
this.label4.TabIndex = 2;
this.label4.Text = "ßáãÉ ÇáãÑæÑ";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(64, 101);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(200, 20);
this.textBox1.TabIndex = 3;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(63, 141);
this.textBox2.Name = "textBox2";
this.textBox2.PasswordChar = '*';
this.textBox2.Size = new System.Drawing.Size(200, 20);
this.textBox2.TabIndex = 4;
this.textBox2.Text = "";
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button1.Location = new System.Drawing.Point(272, 189);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 5;
this.button1.Text = "ÏÎæá";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// oleDbCommand1
//
this.oleDbCommand1.CommandText = "SELECT id, name, [password] FROM names WHERE (id = ?) AND ([password] = ?)";
this.oleDbCommand1.Connection = this.oleDbConnection1;
this.oleDbCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("id", System.Data.OleDb.OleDbType.VarWChar, 15, "id"));
this.oleDbCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("password", System.Data.OleDb.OleDbType.VarWChar, 15, "password"));
//
// oleDbConnection1
//
this.oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=muneer.mdb;Persist Security Info=Fal" +
"se;\0";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(424, 230);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1,
this.textBox2,
this.textBox1,
this.label4,
this.label3,
this.panel1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.Name = "Form1";
this.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ÏÎæá";
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
string sql = "SELECT id, name, [password] FROM names WHERE (id ='"+textBox1.Text+"') AND ([password] ='"+textBox2.Text+"')";
try
{
OleDbDataReader objReader;
//oleDbCommand1.Parameters["id"].Value = textBox1.Text.Trim();
//oleDbCommand1.Parameters["password"].Value = textBox2.Text.Trim();
oleDbConnection1.Open ();
oleDbCommand1.CommandText = sql;
objReader = oleDbCommand1.ExecuteReader();
if(objReader.Read())
{
//ss = objReader["name"].ToString();
objReader.Close();
this.Close();
}
}
catch(ArgumentNullException ex)
{
MessageBox.Show(this,"Error 4"+ex.Message,"Error...");
}
catch(Exception ex)
{
MessageBox.Show(this,"Error 3 "+" \n"+ex.Message,"Error...");
}
finally
{
oleDbConnection1.Close();
}
}
}
}
-----------------------------------------
|
|
|
|
|
|
Hi, my slave-working is making a irc plugin for my c# program in vb...i want to embed the dll in my project so others can't ripoff the component from the program folder...
Is their any way to achieve this?...or perhaps some way to compile two differant projects with two differant languages together resulting in one exe?
|
|
|
|
|
|
Hi, my slave-working is making a irc plugin for my c# program in vb...i want to embed the dll in my project so others can't ripoff the component from the program folder...
Is their any way to achieve this?...or perhaps some way to compile two differant projects with two differant languages together resulting in one exe?
|
|
|
|
|
|
First of all, what's wrong with just shipping an extra DLL? So long as you don't use the registry and rely instead on .config files (which is what you're supposed to do), you don't have to worry about elaborate installations, hence the "xcopy" deployment term, describing .NET's touchless deployment capabilities.
Second, don't embed it as a resource. If you mean VB.NET (instead of VB), there is a way to do it and handle AppDomain.AssemblyResolve but this is a HUGE waste of time and just isn't proper.
You can also compile two modules compiled from different source languages like C# and VB.NET and merge them into a single assembly. Compile one or the other using the target "module". I would recommend that you do this for the VB.NET project. Then, when you compile the other app into an assembly, you use /addmodule to reference the other module and link it into the assembly:
vbc.exe /t:module /out:Plugin.dll *.vb
csc.exe /t:exe /addmodule:Plugin.dll /out:App.exe *.cs See the compiler documentation or type "csc.exe /?" or "vbc.exe /?" to see more information.
Seriously, though, you'd gain a lot more flexibility by having your exe and dll separate, especially if you want to include more plugins through a .config file. There are several articles here on CP about plug-in architectures. Try a search[^] for examples.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I'm building a form so that customer can fill in their data (with a lot of texboxes). I decided to use datagrid. I don't know if I'm on the right track. I was able to build a array of datagrids programmactically. Here is my situation.
From : mm/dd/yy
To: mm/dd/yy
Fill (button)
Grid1 (all of these grids are built programmatcally and added into a placeholder)
Grid2
Grid3
...
Because there are 2 columns From and To
From : mm/dd/yy (<--- user will fill here) (**)
To: mm/dd/yy (<--- user will fill here) (***)
Grid1
From To A B C
blank blnk (user will fill here) (user will fill here) (user will fill here)
....
I want to assist user to fill the date they enter at (**) into the From column of the grid for them. I don't know what to do. I tried to write a piece of code for the button fill above but I failed.
Help me if you can. Thanks
protected System.Web.UI.WebControls.DataGrid[] grids;
public void fill (object sender, System.EventArgs e)
{
string from = frombox.Text;
string to = tobox.Text;
foreach(DataGrid grid in grids)
{
foreach(DataGridItem item in grid.Items)
{
Response.Write("Found");
//TextBox tb = (TextBox)item.Cells[1].FindControl("answerbox");
//string str = tb.Text;
//ls.Add(str);
}
}
}
Errror
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 214: Response.Write("Control not found");
Line 215: }*/
Line 216: foreach(DataGrid grid in grids)
Line 217: {
Line 218: foreach(DataGridItem item in grid.Items)
|
|
|
|
|
HI
Yesterday i had it, but couldnt replicate it, but now I have pin-pointed it.
BUG description: When rendering non-monospaced fonts, DrawString "compresses" the last +-25% of the string that need to be drawn. This can be seen clearly especially with long repetitive strings.
Here is a Control that demonstrates the BUG. Note: the alignment in the 1st 75% is "strected" and the rest is "squashed". Also that the complete width seems to be correct in SansSerif fonts, but not in Serif fonts.
[EDIT] If one clearly define the TextRendering not to use a GridFit type rendering, then it works correctly. Now where did I they leave the ClearTypeNonGridFit option? IMO it bad to change the underlying system's rendering as in the case if you have ClearType enabled. [EDIT]
[INFO] http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q307208[^] [INFO][EDIT] I still dont see how thats gonna solve my problem as it appears MeasureString is the cultprit.[EDIT]
Comments welcome (especially from the MS crowd).
class Drawer : Control
{
StringFormat sf = StringFormat.GenericTypographic;
public Drawer()
{
Text = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
BackColor = Color.White;
Font = new Font(FontFamily.GenericSerif, 24);
}
protected override void OnPaint(PaintEventArgs e)
{
float h = Font.GetHeight();
float w = e.Graphics.MeasureString("f", Font, int.MaxValue, sf).Width;
for (int i = 1; i <= Text.Length;i++)
{
e.Graphics.DrawLine(Pens.DimGray, w * i, 0, w * i, h);
}
for (int i = 1; i <= Text.Length;i++)
{
w = e.Graphics.MeasureString(Text.Substring(0, i), Font, int.MaxValue, sf).Width;
e.Graphics.DrawLine(Pens.DimGray, w , h, w, h + h);
}
e.Graphics.DrawString(Text, Font, Brushes.Black, 0,0, sf);
}
}
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
MS employee: Lets smoke more pot!
This is absurd:
"The default action of DrawString works against you when you display adjacent runs: First, the default StringFormat object adds an extra 1/6 em at each end of each output; second, when grid fitted widths are less than designed, the rendered string is allowed to contract from its measured size by up to an em.
To avoid these problems, do the following:
Always pass MeasureString and DrawString a StringFormat object based on the typographic StringFormat (GenericTypographic).
-and-
Set TextRenderingHint graphics to TextRenderingHintAntiAlias."
It still doesnt answer why MeasureString should return incorrect values...
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I read a book about c# called<microsoft visual="" c#="" core="" reference="">. I find delegate is harder to master than c++'s pointer... I dont know why everybody say that c# is easier to use than c++. sigh...
|
|
|
|
|
Actually,if c# has pointer instead of delegate. It will be perfect
|
|
|
|
|
What don't you get about delegates in particular?
- Nick Parker My Blog
|
|
|
|
|
A delegate is a managed function pointer, and even offers several advantages. First, when compiled (for compilers that support this, as the C# compiler does) the compiler automatically generates asynchronous invocation methods! You can't beat that!
Take the following declarations in C:
BOOL CALLBACK EnumProc(LPCTSTR s);
BOOL EnumSomething(EnumProc proc); In C#, this would look like:
public delegate bool EnumProc(string s);
public bool EnumSomething(EnumProc proc); When you call EnumSomething , you would do so in a similar manner as with C:
bool val = EnumSomething(new EnumProc(MyEnumProc));
private bool MyEnumProc(string s)
{
Console.WriteLine(s);
} In the implementation for EnumSomething , you could even use BeginInvoke instead of Invoke (or the shorthand way where you just use the delegate parameter like a function) for asynchronous invocation.
See Handling and Raising Events[^] and Including Asynchronous Calls[^] in MSDN for more information, in-depth topics, and plenty of examples.
Also, just so you can see there really isn't much different, when interop'ing methods that require a function pointer or P/Invoke functions that require function pointers, a delegate is what you use in lieu of an IntPtr . When the param is marshaled, it is marshaled as a function pointer.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Wow! Thanks Heath. I seem to learn something new each time I read one of your posts. I never knew that you could do Asynchronous calls on delegates.
--Colin Mackay--
EuroCPian Spring 2004 Get Together[^]
|
|
|
|
|
Yep, just a word of warning, though - if the delegate is declared in the current project, the BeginInvoke and EndInvoke methods don't show up in IntelliSense but they're there! If you read the second article link, you can see the generated signatures of those methods; or, you could always compile your project once and examine the method signatures with ildasm.exe.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
this might be a bit of a backwards question but
i want to be able to test if an app has a manifest/themes is enabled
the reason is that i want to make my own controls render with xp style only if the app is supposed to be themed
i need to do this in .net 1.0
any pointers on how to accomplish this ??
(i already have my xp painting code in place , i only need to check if i should enable it or not)
//Roger
|
|
|
|
|
P/Invoke the native method IsAppThemed . Since this is only supported in Windows XP and higher, you can either catch the DllNotFoundException that is thrown in earlier platforms, or use the OSFeature class like below:
public class Test
{
[DllImport("uxtheme.dll")]
private static extern bool IsAppThemed();
public bool Themed
{
get
{
try
{
Version v = OSFeature.Feature.GetVersionPresent(OSFeature.Themes);
return v != null;
}
catch { return false; }
}
}
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi
I am trying to customize by label text by using Graphics.DrawString function. I use it withing the Paint Event Handler of the label (On_Paint() Function in my case). When the form gets loaded, the graphics comes correctly. To update the graphics when the text for label gets changed, i tried calling label1.Invalidate(); and label1.Refresh(); . In both the cases nothing happens...it seems as if the function On_Paint() is not getting executed....
Am I missing an important aspect of GDI Classes or Event Handlers? Please clarify me....
Thanks
Muralidhar
|
|
|
|
|
Is the handler really not getting executed, or does it just seem that way? Put a break point in it or use System.Diagnostics.Debug.WriteLine in your handler and watch your output window when debugging. Control.Refresh will invalidate the client region and force a repaint. So long as you're not removing your PaintEventHandler for the label, it will get called.
Also, if all you're trying to do is modify the text, you might consider encapsulating this into your own class that extends Label . For instance, say you want to prefix the text that's assign the parameter, you could do something like this:
public class MyLabel : Label
{
public override string Text
{
get { return base.Text; }
set { base.Text = string.Concat("Prefix: ", value); }
}
} The default behavior will do the rest, such as painting. If you're trying to control the style of the font, you can use the Label.Font property (inheritted from Control ).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks a lot...
That worked...I have written a class derived from label...
|
|
|
|
|
Hi all,
I have this code that loads-up some plugins(dll files), and I'm having trouble executing them.
Every plugin has a ExecutePlugin(string Commands) method defined.
So when I wan't to execute all of my plugins from my main program I have this code:
foreach ( Type DllType in Plugins )
{
ICowPlugin Plugin = (ICowPlugin) Activator.CreateInstance ( DllType );
Plugin.ExecutePlugin ( "Plugins rox" );
MessageBox.Show ( Plugin.PluginName );
}
and strange is that the MessageBox.Show(Plugin.PluginName); indeed shows the name of the plugin, but code inside of ExecutePlugin() is aparently not executed.
I have a simple MessageBox.Show() inside the plugin's ExecutePlugin and the message box is not shown
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Try debugging your application. Put a breakpoint on the Plugin.ExecutePlugin statement, as well as on the first statement in the implementation of ICowPlugin.ExecutePlugin . As long as all your assemblies are compiled with the DEBUG preproc def (i.e., a Debug build) and loaded into your solution, you should have no problem determining if the method is actually executed (and it should be if no exception is being thrown, which doesn't seem to be the case since the next statement is executed) and if something is going wrong inside the method. An exception might be thrown in the implementation that you're also catching and returning from, so maybe you're not getting the results you want. Debugging this method will help determine the cause of the problem.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi, Im relativlly new to C#, so I dont really know what to look for.
THe method aparently works just fine and is "error-less" becouse when I compiled the plugin the compiller didn't return me any warnings or errors.
THe ExecutePlugin inside the plugin looksliek this:
public void ExecutePlugin ( string Commands )
{
MessageBox.Show ( Commands, PluginName );
}
and liek I said I cen get the PluginName property inside my main programm, but the messagebox dosen't show ...
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
I am just starting out with C# and want to know how can I tell what kinda of project the code was started from by looking at the code. and by project I mean when you create a new project, from the wizard....
Thanks
Ralph
|
|
|
|
|