|
Hi,
I have a client application that is used to read/write a database on my live server. I have a problem if the application is used behind the proxy it cannot establish a connection with the My Sql Server. It works fine if not behind proxy.
Looking forward to hear codeproject professional's comments.
Thank You
|
|
|
|
|
I am trying to copy one dataset to another and calling acceptchanges to update database but it is not working although not giving any error. here is the code.
SqlDataAdapter da2 = new SqlDataAdapter("SELECT * FROM " + DestinationTableName, consql);
DataSet dsDest = new DataSet();
dsDest.CaseSensitive = false;
da2.Fill(dsDest, DestinationTableName);
dsDest.Tables[0].TableName = DestinationTableName;
DataTable dt = new DataTable();
dt.TableName = DestinationTableName;
foreach (DataRow dr in dsSource.Tables[0].Rows)
{
DataRow drdata= dsDest.Tables[0].NewRow();
foreach (DataColumn dc in dsSource.Tables[0].Columns)
{
drdata[dc.ColumnName] = dr[dc.ColumnName];
}
dsDest.Tables[0].Rows.Add(drdata);
dsDest.AcceptChanges();
da2.Update(dsDest.Tables[0]);
}
Whats wrong with above code..?
|
|
|
|
|
|
m making a web application on e-commerce/shopping using c# with ASP.NET . for the same
i need a code(c# with ASP.NET) to add items in a cart. session layer should be there ....and it should be added in the database...later when we go for payment it has to be removed from the cart....
in my application everything is OK but once i log off or once the session expires we wont be able to see the previous items in that cart.i want the items should b there until i go for payment.
will u please help me out..
|
|
|
|
|
ASP.NET 2.0 Visual Web Developer 2005 by D Sussman and A Homer (Wrox, 2006 ISBN 0-7645-8807-9) has exactly this in it.
Two points (a) it's in VB not C# and (b) there's probably a later edition (or at least something like it).
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
manila dahal wrote: i need a code(c# with ASP.NET)
Try a starter-kit[^].
I are Troll
|
|
|
|
|
Hi,
I have a two form application, the 1st form (Main Form) and a rich text box field on the 2nd form for comments. I have a hidden comment field on the 1st and I would like to update the comments field on the 1st form with the comments from the RichTextBox on the second form. How do I do this?
Thank you,
Glenn
|
|
|
|
|
Follow the steps and you will achieve what you want.
1. Declare object of form2 from inside form1.
Form2 f2;
2. In the same manner declare object of form1 from inside form2 (public).
Public Form1 f1;
3. Instantiate form2 from form1 and assign object of form1(f1) to this.
f2 = new Form2();
f2.f1 = this;
f2.show();
Now you have object of form1 in form2.
This way you can pass information of form1 to form2 and by doing reverse you
can pass information of form2 to form1.
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
You should never couple a child object to the parent like this when it's possible the child could exist without the parent. Doing so makes the child non reusable. The correct way to do this is for the child to raise events.
Also, you should not expose fields as public. Fields should be private and exposed via a public/internal/protected property as appropriate. This allows for validation and other logic as required later plus the use of locks for multithreading etc...
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Assuming Form1 is the main form that runs when the application starts and is therefore instanciating Form2 ...
Information can be passed from Form2 to Form1 in 3 ways.
1. When you create your Form2 instance, store it in a private field so you can use it outside of the method that does the instanciation. Have an internal or public property that holds the data you need in Form2 . Form1 can access this when required by using the field.Property.
2. The same as 1, but use a method instead of a property.
3. Create a custom EventArgs class, then in Form2 , create an event and a raising method passing an instance of these args. When Form1 creates the Form2 instance, it can subscribe to the event.
1 and 2 require Form1 to poll Form2 for data, in 3 Form2 signals Form1 when there is new data.
Example of 3 - here[^], and further information about events here[^].
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
hi to all,
I am creating an application for authentication Token and my problem is to read the certificate from usb .
Please if Any body is having any idea about it ; reply as early as possible.
Thank you in advance.
|
|
|
|
|
I imagine it would be a lot like reading a certificate from a hard drive.
EDIT: repost.
|
|
|
|
|
Hi all,
I have two forms. On one form is a text box and the other form hold a data table that is the source of a dataset. Upon entering text in the first form and clicking a button, I want to have the text added to the dataset data table. I have unsuccessfully tried instantiating the data table using DataRow newRow...... as the textbox form doesn't allow me to "see" the data table or the dataset. Can someone point me in the right direction here?
Thanks.
|
|
|
|
|
I'm not sure I follow exactly what you are trying to do, but if your data entry form is accessible from the data table form, just make the input text public and read it from the data table form.
If that's not what you need, then perhaps you could explaining your dilemma a little better and let us know what you've tried so far.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Let me simplify things a bit to be more clear. Let's say I have two forms. There is a textbox on Form1 and I'll just have some default text that resides in the textbox. On Form1_Load shown below, frmCalData is instantiated and shown. frmCaldata has a dataset dsCalData with a data table tblCalData.
private void Form1_Load(object sender, EventArgs e)
frmCalData frmCal = new frmCalData();
frmCal.Show();
I believe I should be eventually calling out something like this:
DataRow row = tblCalData.NewRow();
tblCalData.Rows.Add(textbox1.Text);
However, in the Form1_Load method, I cannot call out tblCalData.
As this is new to me, I am shooting somewhat blind, so any guidance will be greatly appreciated.
|
|
|
|
|
When you try to access tblCalData from Form1, what happens? If it gives you an error, what error is shown?
You should be able to access tblCalData from Form1 as frmCal.tblCalData, but it will need to be set public for it to be accessible.
On the other hand, is there a reason that you need both in 2 separate forms?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
DataRow row = frmCal.dataTable1.NewRow (label4.Text,"0","0");
frmCal.dataTable1.Rows.Add(row);
The error is that 'NewRow' Takes '3' arguments. However, there are three columns and the NewRow method indicates that it will create the same schema as the table so I thought I'd have to have place markers for the other two columns.
I have a separate form for just the data table from the main user interface form.
Updated:
Just changed the above to:
DataRow row = frmCal.dataTable1.NewRow();
row[0] = label4.Text;
frmCal.dataTable1.Rows.Add(row);
That works fine. Thanks for keeping me scratching my head
modified on Wednesday, May 5, 2010 10:07 PM
|
|
|
|
|
I know how it goes - sometimes it can be frustrating figuring things out, but it feels so nice when it finally works.
Glad to hear you got it working!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
|
I have the following class:
class Program
{
static void Main()
{
}
public enum AnimType
{
StickMan
}
public enum StickMan
{
Walk,Run
}
}
This class is used to demo-straight the problem im trying to solve at a simplistic level as otherwise I would have to paste lots of code which is never good.
So that I could use :
Dictionary<(AnimType,STickMan),Animation> animation = new Dictionary<(AnimType,STickMan)();
to get this working:
animation .Add(AnimType.StickMan,StickMan.Walk,new WalkAnimation());
This would allow me to return an Animation object depending on what the animation type (stickman) and the unique animation states (walk,run).
I know that the syntax used for this dictionary is incorrect but its the best way I know how to display it so sorry in advance!
modified on Wednesday, May 5, 2010 2:17 PM
|
|
|
|
|
I would suggest breaking this down a bit more logically... Assuming you plan on adding more animation types, each with its own list of animations, you're going to have a huge collection of enums and no real organization at all... So here's what I would do...
Make a StickMan class, and have it implement a common interface (So you can add more similar classes later)... Let's just call it IAnimationContainer, for example:
public interface IAnimationContainer
{
Animation GetAnimation(string name);
}
public class StickMan : IAnimationContainer
{
private Dictionary<string, Animation> _animations = new Dictionary<string, Animation>();
public StickMan()
{
_animations.Add("Walk", new WalkAnimation());
}
public Animation GetAnimation(string name)
{
return _animations[name];
}
}
Then, you use your dictionary to index AnimTypes to the actual classes...
animations.Add(AnimType.StickMan, new StickMan());
And to get the actual animation:
animations[AnimType.StickMan].GetAnimation("Walk");
|
|
|
|
|
That is brilliant, I have had a hard long day and feel pretty stupid now
...4 Exams in one day !
Thanks !
|
|
|
|
|
can you correct this document the code pls ,thanks
namespace eControlCevertest.lib.Primitives
{/// <summary>
/// la class Gline est un class mere
/// </summary>
public sealed class GLine
{
#region Variables
private bool m_IsDataCorrect;
private LineDefinition m_ContentFormat;
private short
m_CRCComputed = -1,
m_CRCGiven = -1;
private string
m_Code,
m_Value;
#endregion
#region public Accessors
/// <summary>
/// Contient le Code de la donnée etdonne la v aleur, conformement au CDC GiEGLAN
/// </summary>
public string Code
{
get { return m_Code; }
set { m_Code = value; }
}
public LineDefinition ContentFormat
{
get { return m_ContentFormat; }
set { m_ContentFormat = value; }
}
/// <summary>
/// Contient la valeur de la donnée et calcule le ,
/// </summary>
public string Value
{
get { return m_Value; }
set
{
m_Value = value;
ComputeState();
}
}
public short CRCComputed
{
get
{
return m_CRCComputed;
}
}
public short CRCGiven
{
get { return m_CRCGiven; }
set
{
m_CRCGiven = value;
ComputeState();
}
}
public bool IsDataCorrect
{
get
{
return m_CRCGiven != -1 && m_IsDataCorrect;
}
}
/// <summary>
///
/// </summary>
public bool IsDefinitionAvailable
{
get
{
return m_ContentFormat != null;
}
}
#endregion
#region public non default Constructs
/// <summary>
// Constructeurs
/// </summary>
public GLine(string code, string value, short givencrc)
{
m_Code = code;
m_Value = value;
m_CRCGiven = givencrc;
ComputeState();
}
/// <summary>
// Constructeurs .
/// </summary>
public GLine(string code, string value)
{
m_Code = code;
m_Value = value;
m_CRCComputed = Common.CalcCRC(value);
}
/// <summary>
// Constructeurs .
/// </summary>
public GLine(string code, LineDefinition definition)
{
m_Code = code;
m_ContentFormat = definition;
}
#endregion
/// <summary>
/// fonction pour Calculer les valeurs.
/// </summary>
private void ComputeState()
{
m_CRCComputed = Common.CalcCRC(m_Value);
m_IsDataCorrect = m_CRCGiven == m_CRCComputed;
}
}
}
|
|
|
|
|
What do you mean? Edit your question to make it descriptive and post only the relevant code within "pre" tags.
|
|
|
|
|
toto_2010 wrote: can you correct this document the code pls ,thanks
I appreciate that English is probably not your first language, but can you try rewording this to make a clearer question?
It's time for a new signature.
|
|
|
|