|
hi all i have this pro on hand now.. i have downloaded some sample database applications from the internet..however when i want to debug it i gives me the error--An unhandled exception of type "system.Data.OleDb.OledbException" occurred in system.data.dll
does this errors occur due to where the dB file is located..is it correct? can someone out there help will this pro? and maybe guide me to correcting it ..thanks in advance..
an extract on of codes where the problem is highlighted is below:the pro is bold...thanks in advance
private void fclsMain_Load(object sender, System.EventArgs e)
{
m_cnADONewConnection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\temp\contacts.mdb";
m_daDataAdapter =
new OleDbDataAdapter("Select * From Contacts",m_cnADONewConnection);
OleDbCommandBuilder m_cbCommandBuilder = new OleDbCommandBuilder(m_daDataAdapter);
m_daDataAdapter.Fill(m_dtContacts);
this.ShowCurrentRecord();
|
|
|
|
|
You need
cnADONewConnection.Open();
before
m_daDataAdapter.Fill(m_dtContacts);
|
|
|
|
|
DataAdapter handles the open and close connection in the Fill method
only two letters away from being an asset
|
|
|
|
|
What is the message in the exception? This will tell you (and us) more of what is going on.
only two letters away from being an asset
|
|
|
|
|
Here is my problem
I want to print the contents of the datagrid c# in ASP.NET 2.0 but the constraints are:
1>When the user clicks the print button all the records till the end even the data is not visible to the user should get print.
2>It should print according to the page size that is the user tells how many records has to be dispalyed at a time on a webpage.
3>At every page the page header and footer sholud be displayed defined by the user
4>How to access the page footer and header programatically inorder to avoid to print the url at the end of the page.
Does any one knows the solution please reply it's urgent!
sunny
|
|
|
|
|
Hi,
you are in the wrong board. ASP.NET Question should be asked in ASP.NET Board. Secondly you just use a subject that is corresponding to the problem and not just "hi". Use a subject as: "Printing a datagrid"
I can't help you, as I don't have an active ASP project and my last one was mutiple month ago.
Regards,
Ingo
------------------------------
PROST Roleplaying Game
War doesn't determine who's right. War determines who's left.
|
|
|
|
|
I need to run zip a file(s) using winzip from within my c# application. Can anyone point me to documentation / example of how to accomplish that. Thanks in advance - SS -
|
|
|
|
|
|
Then include the J# libraries and you can do it programmatically.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Why zip with winzip when you can do it in code: SharpZipLib[^]
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
If I have an xml file such as below:
<printItAll>
<chatMessage>
<xml1>username</xml1>
<xml2>message here!</xml2>
<xml3>red</xml3>
<xml4>arial</xml4>
<msgID>3</msgID>
</chatMessage>
<chatMessage>
<xml1>Ben Griffiths</xml1>
<xml2>some random message</xml2>
<xml3>red</xml3>
<xml4>arial</xml4>
<msgID>4</msgID>
</chatMessage>
</printItAll>
How would I count the <chatMessage> elements, and how could I loop through them? At the moment my file only reads the first one. Here is my current code:
XmlDocument xDoc = new XmlDocument();
xDoc.Load("my_xml_file.xml");
XmlNodeList xml1 = xDoc.GetElementsByTagName("xml1");
XmlNodeList xml2 = xDoc.GetElementsByTagName("xml2");
XmlNodeList xml5 = xDoc.GetElementsByTagName("msgID");
string chat_memberU = (xml1[0].InnerText + ": ");
string chat_message = (xml2[0].InnerText);
int latestID = Int32.Parse(xml5[0].InnerText);
Many thanks, Ben.
-- modified at 11:19 Thursday 3rd August, 2006
|
|
|
|
|
SoftcodeSoftware wrote: count the <chatmessage> elements
Retrieve the Count property of one of the XmlNodeList s.
SoftcodeSoftware wrote: how could I loop through them?
Iterate over the XmlNodeList s you've already got.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi, thanks,
I actually realized it was in an array just now lol, got it working
|
|
|
|
|
I have a code that monitors the electrical loop. Once the button is pressed, it would loop until the button is pressed. The problem is that when the code loops (I use while loop), the button cannot be pressed and the programs acts like as if it is locked up. How do I get the program check for any event while looping? Like for example, in borland c++, it uses "Application->ProcessMessages()".
How do I apply this to Visual Studio.NET?
-- modified at 11:16 Thursday 3rd August, 2006
Code sample below:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
namespace loop_test
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NumericUpDown numUpDn;
private System.Windows.Forms.Button btnLoop;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.btnLoop.BackColor = System.Drawing.Color.Red;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnLoop = new System.Windows.Forms.Button();
this.numUpDn = new System.Windows.Forms.NumericUpDown();
((System.ComponentModel.ISupportInitialize)(this.numUpDn)).BeginInit();
this.SuspendLayout();
//
// btnLoop
//
this.btnLoop.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.btnLoop.Location = new System.Drawing.Point(56, 16);
this.btnLoop.Name = "btnLoop";
this.btnLoop.Size = new System.Drawing.Size(176, 96);
this.btnLoop.TabIndex = 0;
this.btnLoop.Text = "Loop Stopped";
this.btnLoop.Click += new System.EventHandler(this.btnLoop_Click);
this.btnLoop.BackColorChanged += new System.EventHandler(this.btnLoop_BackColorChanged);
//
// numUpDn
//
this.numUpDn.Location = new System.Drawing.Point(72, 136);
this.numUpDn.Name = "numUpDn";
this.numUpDn.TabIndex = 3;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 174);
this.Controls.Add(this.numUpDn);
this.Controls.Add(this.btnLoop);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Loop interruption Test";
((System.ComponentModel.ISupportInitialize)(this.numUpDn)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnLoop_Click(object sender, System.EventArgs e)
{
if (this.btnLoop.BackColor == System.Drawing.Color.Red)
this.btnLoop.BackColor = System.Drawing.Color.Lime;
else
this.btnLoop.BackColor = System.Drawing.Color.Red;
}
private void btnLoop_BackColorChanged(object sender, System.EventArgs e)
{
while (this.btnLoop.BackColor == System.Drawing.Color.Lime)
{
this.numUpDn.Value += 1;
this.numUpDn.Update();
Thread.Sleep(500);
}
}
}
}
|
|
|
|
|
Can't you just use a seperate thread for your loop?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use a seperate processing thread and a ManualResetEvent to trigger the stop/start
only two letters away from being an asset
|
|
|
|
|
The method you're looking for is Application.DoEvents .
Nevertheless I also think it would be a much nicer way to do the loop inside of a separate thread.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Yeah... seems that "Application.DoEvents()" in the while loop does the trick. Thanks!
|
|
|
|
|
Hello
There is a method that do the same thing as ProcessMessages in C#, it's called Application.DoEvent() . So it process all the messages in your queue including the Button.Click
Here is a simple class that will do what you wany. Note that Button1 starts the loop. Button2 ends it:
public partial class Form1 : Form
{
bool Go;
public Form1()
{
InitializeComponent();
Go = true;
}
private void button1_Click(object sender, EventArgs e)
{
Go = true;
int temp = 0;
textBox1.Text = "0";
while (Go)
{
temp++;
textBox1.Text = temp.ToString();
button1.Capture = false;
Application.DoEvents();
}
}
private void button2_Click(object sender, EventArgs e)
{
Go = false;
}
}
Regards
|
|
|
|
|
Hi all,
I have a continuous stream of packet data going through my asynchronous socket connection. My question is how can I tell in the EndReceive callback method where one package of data ends and another begins? I coded the socket class in C# 1.1.
Thanks in an advance.
Ken
|
|
|
|
|
You have to have a delimiter in the data. And once you read in the delimiter in the callback, you'll know you got to the end of one message/stream and you're now reading for the next message/stream.
So a very simple protocol is needed to delimit your messages. You have to make sure you read all the message as it may/may not (certainly not guaranteed) to be send in a single socket.send.
|
|
|
|
|
I like to prefix my messages with a length rather than delimit them.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
The more appealing and real world solution for all types of data transfer is to prefix each messaeg with its length.
Procedure is as follow.
Sending Part:
1) Calculate the Number of bytes produced by a message.
2) Store length as an integer value.
3) Convert the Length (integer) into bytes using BitConverter.GetBytes(messageLength) method.
4) Send these bytes on stream.
5) Send the original message.
Receiving Part:
1) Read 4 bytes from the stream Asynchronously.
2) Convert these bytes into integer value using BitConverter.ToInt32(buffer,0)
3) Now creat a Memory Stream and loop on it untill that message size is met.
Its the best technique in my knowledge and supports in Network delay situation for other type of data (Not String)
If you have further queries, feel free to conact me
rizwansharp@hotmail.com
Best Regards,
Rizwan
|
|
|
|
|
I have to run several secuential proceses, some of them impersonated from the main identity of the program.
Using .Net 2.0, the a "ProcessStartInfo" instance, can impersonate, but the password must be a "SecureString".
I have the Username and the Password on a encrypted file, but when I decrypt the tye file, password this make is readable (wich we all know is bad thing).
The constructor of "SecureString", does not take a String as parameter, so I mahe this (check the sample):
System.Diagnostics.ProcessStartInfo _ps = new System.Diagnostics.ProcessStartInfo();
_ps.FileName = _command;
_ps.CreateNoWindow = false;
_ps.Arguments = _arguments;
_ps.UseShellExecute = false;
SecureString _psw = new SecureString();
string _password = "123456";
foreach (char Character in _password.ToCharArray())
{
_psw.AppendChar(Character);
}
_psw.MakeReadOnly();
_ps.LoadUserProfile = false;
_ps.UserName = "User";
_ps.Password = _psw;
System.Diagnostics.Process _process = new System.Diagnostics.Process();
_process.Start(_ps);
_process.WaitForExit(); Now There is way to solve the clear-password-in-memory problem?
The user account is a restricted account, but with access to some processes wich we don't want to be publicaly accessed.
I'm on a Fuzzy State: Between 0 an 1
|
|
|
|
|
If you want to be secure, you can never store the password as a plain string. You'll need to read in the password character-by-character, decrypting each character. Once you've done this, you can clear out the contents of your character array.
The reason this is more secure is that strings, once created, cannot be cleared (since they are immutable). The .NET GC can even move strings around in memory, thus leaving your password in multiple places in memory. thus, there's a good chance someone inspecting your process's memory or the page file could discover your password. If you read your password in as a character array, you can construct a SecureString from it, after which you should immediately clear your character array. This makes it extremely difficult for someone to discover your password as the window of opportunity to intercept your password is very low. Here's[^] an excellent article on the purpose and uses of SecureString.
Optionally, you could read the password in as a string, then use unsafe code to clear the string in-place. I don't recommend doing this, but if you're up to it, here's an article[^] that will get you started in the right direction.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|