|
Actually, this is an easy question, about converting formats. int.TryParse is how you get an int out of a string.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
falles01 wrote: At the moment what is happening is its saving the firstname, lastname correctly, but the rest of the ID columns are null.
Of course they are. You don't specify any values for them.
falles01 wrote: It is updating the other tables with the string entered but what I need is the emplyee table to update with the corresponding ids. Is this alot more complicated then i thought?
As you obviously thought that it would happen automatically, yes, it's a lot more complicated than that.
You have to add the other values first, and get the id that is created for each record:
declare @RoleId int<br />
insert into [ROLE] ([ROLE]) values (@ROLE)<br />
set @RoleId = scope_identity()
Then you can use these values when you insert into EMPLOYEES.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thank you, but I decided to just use my insert statement for now as that works.
My question now is how exactly do I get selected values of a checkedlist box and store it as ID numbers in the database. I had something like this which is obviously wrong. It works for the comboboxes but then I heard you need for loops to check multiple selections in a checkedlistbox. Feel free to just change my code.
if (this.techSkillsCheckListBox2.CheckedItems.Count > 0)
{
label1.Text = "worked";
foreach (string item in this.techSkillsCheckListBox2.CheckedItems)
{
string sql = "INSERT INTO employees(Firstname,Lastname,RoleID,DivisionID,ManagerID,TechnicalSkillsID) Values ('" + FirstnameText.Text.ToString() + "' , '" + Lastnametext.Text.ToString() + "' , " + RolecomboBoxTest.SelectedValue.ToString() + "," + DivisioncomboBox2.SelectedValue.ToString() + " , " + ManagercomboBox1.SelectedValue.ToString() + " , " + techSkillsCheckListBox2.SelectedValue.ToString() + ")";
Don't worry this won't be used commercially so I was told not to worry about injection attacks until I can get these correct.
Thank you for helping out.
|
|
|
|
|
falles01 wrote: It works for the comboboxes but then I heard you need for loops to check multiple selections in a checkedlistbox.
If you have a control that allows mutiple selections, then you have to use the SelectedItems property instead.
You also have to change your database design so that it allows for multiple values.
---
single minded; short sighted; long gone;
|
|
|
|
|
It doesn't allow multiple selections though. Okay well apart from the database side of things I believe I have to use a 'for' loop.
why does the following return an error?: The name 'Checked' is not permitted in this context. Only constants, expressions, or variables allowed here. Column names are not permitted.
foreach (int indexChecked in techSkillsCheckListBox2.CheckedIndices)
{
string sql = "INSERT INTO employees(Firstname,Lastname,RoleID,DivisionID,ManagerID,TechnicalSkillsID) Values ('" + FirstnameText.Text.ToString() + "' , '" + Lastnametext.Text.ToString() + "' , " + RolecomboBoxTest.SelectedValue.ToString() + "," + DivisioncomboBox2.SelectedValue.ToString() + " , " + ManagercomboBox1.SelectedValue.ToString() + " , " + techSkillsCheckListBox2.GetItemCheckState(indexChecked).ToString() + ")";
SqlCommand sqlC = new SqlCommand(sql, myConnection);
}
}
Anyone. I have been baffled by this for 8 hours. Its especially annoying when it was so easy to work out the combobox selections.
Thanks again.
|
|
|
|
|
Hey all,
I was looking for a way to iterate through all properties for a given control, but am only finding ways to access individual properties.
I am generating lists of all controls on a target form, but would also like to list all properties for each.
Regards.
-- modified at 18:48 Sunday 2nd September, 2007
|
|
|
|
|
ushering wrote: I am generating lists of all controls on a target form, but would also like to list all properties for each.
Use reflection. See the documentation for the System.Reflection namespace
Off the top of my head something like this will get you all the properties on a class (not just controls, any class)
Type controlType = myControl.GetType();
PropertyInfo[] properties = controlType.GetProperties();
DISCLAIMER: This is as I remember it, I haven't checked that the real methods are exactly as stated.
|
|
|
|
|
Hello
How i can know when the user press the back space button
i work in the key_press event but how to specify the back space:
if e.keychar = ...
Thanks a lot
Assaf
|
|
|
|
|
Try something like:
Convert.ToInt16(e.KeyChar) == 8
Replace 8, which is ASCII for backspace, with other values you may want to trap.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The event has an event args, which incudes an instance of the Keys enum. There is a Keys.Backspace.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have 4 textbox where in each one i write 4 char and the 5th will be written in the next one
i want also when deleting from any one of these textbox when i delete 4 chaacere automatically i go to one before and begin to delete the last charactere in it.
how i can do that ???
Thanks in advance
Assaf
|
|
|
|
|
Assaf82 wrote: I have 4 textbox where in each one i write 4 char and the 5th will be written in the next one
So, handle the key up event, check if your control has four characters, and if so, move focus to the next one
Assaf82 wrote: i want also when deleting from any one of these textbox when i delete 4 chaacere automatically i go to one before and begin to delete the last charactere in it.
Same sort of thing
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello all,
I was trying to use Tao framework 2.0 for C#.net and OpenGL. However, the tessellator in that version seems to be broken. Does anyone know of a way to tessellate a concave polygon (described by boundary only verticies) into a convex polygon (either save the verticies of the tessellated object with edge flags or into a format readable by OpenGL)?
Thanks,
Mike
P.S. If someone got The Tao Framework's tessellator to work, please let me know which version.
Gaming at the GuildofBlades.com is the only way to really experiece the level 99 Soul-Sucking Sword!
|
|
|
|
|
Take your vertexes that describe the boundary and order them. Then find the centroid point. Then make a triangle fan around that centroid.
Hope that helps.
|
|
|
|
|
I do not believe that will work. For instance:
Think of the letter: "U". The centroid is located in the bottom part of the U, but you cannot create a triangle fan around this point without making the U into a UV hybrid (pretty much a U with a V inside).
If I misunderstand, please correct me.
Thanks,
Mike
FREE 28 player online game @ http://www.1483online.com where the community drives enhancements to the game!
|
|
|
|
|
Hmmmm, misread that as convex, not concave :P
I think theres some routines in the GL Utility library or maybe in GLUT to do this. (Been a while since I've done any graphics programming
|
|
|
|
|
Hi there,
I want to list all links of website a) with my c# app.
Another website b) has an inline frame with the website a).
Using firefox I just klick in the iframe and then "Current frame -> view source".
Now i want to do the same in my application by accessing webBrowser.Document.Window.Frames[0], but i always get an "UnauthorizedAccessException was unhandeld" error form visual studio.
(I have to mention that, website a) is a third party website and not mine!)
But why can firefox access this site and list all the links and i can't?
any suggestions?
|
|
|
|
|
A good starting point would be that Firefox is not using the IE component. You perhaps need to check the docs and see what the right method is for you to use.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
It doesn't seem to be a general IE problem, i just tried the same with IE7: it works. But still not in my application
|
|
|
|
|
*sigh*
I am suggesting that you need to read the docs to find out how to get at the source, obviously the method you're trying to use is not working.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have few basic queries...pLease help!!
a) Can we have multiple Main methods in one class....? If yes how?
b) Can i have Main Method which returns otherthan Int value ?
Thanks!!
Thanks!!
|
|
|
|
|
a - of course not. You can only have one entry point. That entry point can call any other methods you like, and do it based in command line arguments if you'd like.
b - no.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Class MyClass contains a number of FindAll() methods in parent classes:
class MyClass: ActiveRecordBase<myclass> {... }
public abstract class ActiveRecordBase<t> : ActiveRecordBase {
protected ActiveRecordBase();
public static T[] FindAll();
public static T[] FindAll(params ICriterion[] criteria);
public static T[] FindAll(DetachedCriteria criteria, params Order[] orders);
public static T[] FindAll(Order order, params ICriterion[] criteria);
public static T[] FindAll(Order[] orders, params ICriterion[] criteria);
...
}
public abstract class ActiveRecordBase : ActiveRecordHooksBase {
protected ActiveRecordBase();
protected internal static Array FindAll(Type targetType);
protected internal static Array FindAll(Type targetType, params ICriterion[]
criteria);
protected internal static Array FindAll(Type targetType, DetachedCriteria
detachedCriteria, params Order[] orders);
protected internal static Array FindAll(Type targetType, Order[] orders,
params ICriterion[] criteria);
...
I need to invoke MyClass parameterless FindAll() method using Reflection.
I tried the following code but GetMethod() returns Ambiquous match found
exception.
How to run parameterless FindAll() method ?
How to add required method signature to GetMethod() parameters or other
solution ?
Type t = Type.GetType("MyClass, MyDll");
// this line causes Ambiquous match found exception :
MethodInfo mi = t.GetMethod("FindAll",
BindingFlags.Public |
BindingFlags.FlattenHierarchy |
BindingFlags.Static);
IList<object> list = (IList<object>)mi.Invoke(null, null);
Andrus
Andrus
|
|
|
|
|
Hi
You need to be more specific regarding the method that you want to invoke, when you are using reflaction on an object that have overloading methoods.
try using the following instruction :
MethodInfo mi = t.GetMethod("FindAll", BindingFlags.Public | BindingFlags.Static, null, Type.EmptyTypes, null);
|
|
|
|
|
My problem is, that I want to use 'objects', or what I should call them, in other functions than the one they were created in. For example:
public void button1_Click(object sender, EventArgs e)<br />
{<br />
StreamReader SR = new StreamReader(@"C:\test.txt");<br />
}
Since the StreamReader named SR is defined in button1_Click, I can't
access it's functions - for instance, SR.Write() - in other event handlers
or functions. For example, if I create a new event handler for a button called button2, and type SR, it can't find it, since it is defined in button1_Click.
How do I fix this? How can i access SR's functions in another event handler?
Hope you could understand it
- And yes, I know that I just could define the StreamReader outside a function/event handler, but I still want this one to work.
- Virtual1ty
|
|
|
|