|
|
I am not using stored procedures, my table looks like this:
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| ProviderID | int(11) | | PRI | NULL | auto_increment |
| CompanyTitle | varchar(255) | YES | | NULL | |
| CompanyEmail | varchar(50) | YES | | NULL | |
| Website | varchar(50) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
The value of ProviderID is automatically generated by the database, to insert data into the table, I am using the following code:
MySqlCommand myInsertCmd = new MySqlCommand(
"INSERT INTO myTable (ComapanyTitle, CompanyEmail, Website, ContactPerson, AddressID)
VALUES(?CompanyTitle, ?CompanyEmail, ?Website, ?ContactPerson, ?AddressID)", myConnection);
myInsertCmd.Parameters.Add("?CompanyTitle", MySqlDbType.VarChar,
255, "CompanyTitle");
myInsertCmd.Parameters.Add("?CompanyEmail", MySqlDbType.VarChar, 50, "CompanyEmail);
myInsertCmd.Parameters.Add("?Website", MySqlDbType.VarChar, 50, "CompanyEmail);
myAdapter.InsertCommand = myInsertCmd;
now, whenver I get a new row, I immediately insert it into the database, like this:
myAdapter.Update(myDataTable);
Is there a way, I can get the primaryKey of the newly insert row?
Thanks...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
|
Ok, I am lost with these UserControls and passing inforamtion between them.
I have two projects set up in my solution. The first project contains a form and refrences the other one. The other one has my UserControls and Person Class in it.
The Design is:-->
I have a form and on that form I have two of my own usercontrols.
One is a control with three text boxs on it and an add button and a cancel button. the other UserControl has just a listbox.
What I want to do is have the user fill in the text boxes with personal information (name,age)
and then hit the add button and have that displayed in the list box on the other userControl.
Where I'm having trouble is when I'm trying to access the listbox from the add button event.
Since the list box is in another usercontrol I just can't say this.listbox1.text = whatever" . Can someone help me on this?
(FOR RIGHT NOW IT COULD BE JUST A WORD, I JUST NEED TO UNDERSTAND USERCONTROL INTERACTION when placed on a form separately)
Thanks.
The greatest gig .... LIFE!
|
|
|
|
|
Why to use two UserControls? Wouldn't be two GroupBoxes better?
OK, if you have separated UserControls which share some data, put these data into higher level of hierarchy.
An other way is to make reference in one control to another one, or one's ListBox (via property).
If I would solve this problem myself, I would use some collection (like PeopleCollection). The Add button would be in second UserControl, which controls the collection and keeps one person active. First UserControl would just edit the properties of Person and contains some Apply button which changes the properties of active person (first control contains some ActivePerson property).
Hope this helps a bit.
|
|
|
|
|
I have a C DLL that defines a structure like this
<br />
struct Data<br />
{<br />
int iLength;<br />
UCHAR *buff;<br />
<br />
};<br />
<br />
void AllocateData(Data *pData);<br />
void FreeData(Data *pData);<br />
The buffer inside the structure is allocated inside the C DLL and the buffer lenght is provided in the iLength upon return.
I want to use by creating C# marshalling layer to these function in C#. I have the declaration like this
<br />
[ StructLayout( LayoutKind.Sequential )] br />
public struct Data<br />
{<br />
public int iLength;<br />
}<br />
<br />
[ DllImport( "Data.dll", <br />
EntryPoint="AllocateData", <br />
ExactSpelling=true, // Bypass A or W suffix search<br />
CharSet=CharSet.Ansi, // We want ANSI String<br />
CallingConvention=CallingConvention.Cdecl ) ] br />
public static extern void AllocateData(ref Data data);<br />
<br />
I cannot understand what to use for UCHAR pointer and how to allocate the structure before calling the DLL function.
|
|
|
|
|
Hello gurus,
I am fighting with the MdiChildActivate event.
I would like to know how this works. There is no sample in the MSDN and this event seems to be mysterious: it seems that nobody has used this on this forum. The reserach gave me no result
So, what I need to do is the following:
When an mdi child is brought to front by clicking on it, I wish to know which child is this in order to refresh the main window title, its properties (via a PropertyGrid placed in the main MDI form) and selecting the corresponding node (in its 'solution explorer' which is a TreeView ). My application handles 3 types of different documents.
Can someone help me and showing me a code snippet please? I'm not familiar with MDIs in C#. Sorry for asking the question.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Hello,
Is there a nice way of masking the textbox, so that if user has
the amount in the textbox = 45000, the textbox will display it as money amount like that: $ 45,000.
Thank you in advance.
|
|
|
|
|
zaboboa wrote:
Is there a nice way of masking the textbox
There used to be a control called the Masked Edit that made this simple. But I don't think you can put this control on a current Windows Form.
But you can make your own inherited control to do the same thing. Just inherit from TextBox and override the OnKeyPress method to modify the text entered by the user according to the desired mask. You could design it such that the constructor takes a definition of the mask as a parameter.
Sound like too much work? Then just use this[^].
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
instead of using onkeypress why don't u use on text change; what about pasting in to the control. But u are using data bound controls try to see BaseBindingManager.Format and .Parse events
|
|
|
|
|
I don't understand? What's BaseBindingManager? Who will that relate to my TextBox?
Thank you
|
|
|
|
|
I have a dialog form and appears on the top of MDIContainer (frmMain)
and I want when the user close the dialog form then an MDIChild should
be open on the frmMain. I tried:
myMDIChild.MdiParent = frmMain();
myMDIChild.Show();
but it didn't work.. I also tried:
frmMain MainForm = new frmMain();
myMDIChild.MdiParent = MainForm;
myMDIChild.Show();
with no luck. I am not getting any error message but the MDIChild form
is not openning..
Many Thanks,
Jassim Rahma
|
|
|
|
|
Hi,
In the parent window do the following:
myMDIChild.MdiParent=this;
MDIChild.Show();
This code has to be called in the frmMain() class.
Fred.
There is no spoon.
|
|
|
|
|
but the container is not (this).. i am running this code from frmNew() but the mdi container is frmMain()
|
|
|
|
|
in that case, set the IsMdiContainer to true and set the MdiParent property of the myMDIChild class to the new created form.
This should work.
Fred.
There is no spoon.
|
|
|
|
|
let me understand..
my main form is frmMain
my child form is frmChild
the active dialog is frmDialog
a user clicked a button which shows a frmDialog and when the user click on the button on the frmDialog it should close it and open frmChild within the container (frmMain)
so you want to say in frmDialog i should have this:
frmData frmChild = new frmData();
frmChild.MdiParent = frmMain();
frmChild.Show();
I tried that but getting this error:
dialog_form.cs(258): 'Ezi_Life.frmMain' denotes a 'class' which is not valid in the given context
|
|
|
|
|
Is this what you're looking for?
in MDI main form:
private void menuItem1_Click(object sender, System.EventArgs e)
{
DialogForm aDialogFormGUI = new DialogForm();
if (aDialogFormGUI.ShowDialog()== DialogResult.OK)
{
ThirdForm aThirdFormGUI = new ThirdForm();
aThirdFormGUI.MdiParent = this;
aThirdFormGUI.Show();
}
}
On the Dialog form in the Close event or Click;
DialogResult = DialogResult.OK;
Hope this helps.
|
|
|
|
|
yes.. it worked.. than you very much
can i ask one more question please
how can i run one instance of MDIChild so that if the user invoked the same option again it will not open a new MDIChild.. t should just bring the already openned MDIChild to front..
|
|
|
|
|
Don't know if this is the best way but...
In your MDI Main create a method which passes a temporary Form as a parameter then iterate through all open forms to return the index of the form:
int formIndex = -1;
int i = 0;
foreach (Form cf in this.MDIChildren)
{
// compare the Form you passed with all open Forms
if (passedForm.GetType() == cf.GetType())
{
formIndex = i;
}
i++;
}
Replace the code in the if statement of the dialogresult to:
ThirdForm tempForm = new ThirdForm();
int frmIndex = IndexOfForm(tempForm);
tempForm.Dispose();
// The form is not open
if(frmIndex == -1)
{
ThirdForm ThirdFormGUI = new ThirdForm();
ThirdFormGUI.MdiParent = this;
ThirdFormGUI.Show();
}
// The form is already open
else
{
this.MdiChildren[frmIndex].BringToFront();
}
|
|
|
|
|
NNTP is a thing of the past...its kina dead and people who use forums a lot have a hard time opening the browser and navigating to their thread and stuff. So i thought i'd make a forums to NNTP covertor...by using screen scraping to rip data off the webpages and convert them in the NNTP Usenet msgs form. IS it even remotely possible in C#?
|
|
|
|
|
Possible? Yes. But not practical at all. You'd have to write code to interpret each individual site. And if the site changes their web page, you're re-writing your code.
I thought this is what RSS was for...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i get yor point dave but the problem with RSS lies in the fact that i can read the post but i can reply to them or post new ones. It's kind of a one way system.
|
|
|
|
|
I agree Daves remarks about the difficulty of generating NNTP data from a webpage. The only practical IMO way to do so would be to work from the backend, the easiest way would probably be to use NNTP as the message store and then build the webversion as an NNTP gateway.
Despite it's age, for high volume sites a good NNTP client is far superior to a webUI. Some of the best ones can approach parity, but are much more dependent on having a high speed, always on, connection which not everyone does.
|
|
|
|
|
Hi all,
I am using the word.application - class. From where do I get the windows handle HWnd or the processID of
the started application ?
Thanks for your help
Frank
|
|
|
|
|
Hi. I think this part of code help you
public void OnStartupComplete(ref System.Array custom)
{
Word wApp= (Word.Application)applicationObject;
}
So use wApp to get all data, you need
Igor.
|
|
|
|