|
Hi
I have the following code which is counting how many instances of room_code there are in table room_schdule. I know there is two counts of it in there, but my if statement at the bottom is not working, any clues?
cheers
string test0003 = "Select count (room_code) from room_schedule where room_code = '" + room_code + "'";
string max5;
SqlCommand cmd01 = new SqlCommand();
cmd01.Connection = con2;
cmd01.CommandText = test0003;
max5 = cmd01.ExecuteScalar().ToString();
if (max5 < 2)(it shouldnt perform this statement but it is)
do something
else
do something
|
|
|
|
|
Try
<br />
int imax5 = Convert.ToInt32(cmd01.ExecuteScalar());<br />
if (imax5 < 2)<br />
{<br />
...<br />
}<br />
The problem is "string" < "integer" - I wonder why your compiler is processing this without warning.
|
|
|
|
|
thanks that sorted it cheers
|
|
|
|
|
Hai i am doing program using list i need to add item to list using first,next,last buttons contioniously when i press previous button it should display the previous item in the list plz any on help me in this case
|
|
|
|
|
well.. the last item in the list will be the total number of items... -1
Actually, -2, since arrays always start at 0.
Then after that everytime you click previous you go one lower. So you'd have to have some variable for the current item your looking at.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
You can use the LinkedList( Of T) or use the index (like the other poster mentioned) ... it's not that hard
|
|
|
|
|
hi
1-i have a detaset that filled with a sp
2-i added a column later to sp
3-i go to dataset designer and tried to configure it
4-the new column does not exists in dataset column list
5-i check the connection string , i ran sp from server explorer and management studio 2005 both worked, i refresh my solution refresh my server explorer,reboot my compter, i taked deep breathes,...
none of them helped , so can u help me?
I Wish the Life Had CTRL-Z
|
|
|
|
|
Hi,
I want to write a windows app that will switch my network connections.For example if i have three service providers and if the one i am using now goes down i can switch to the other on a button click.
i plan to keep three buttons and on the buttonclick of these plan to change the connections.ie button1 will connect met to one particular providers internet connection and hence forth regarding the other buttons.I am stuck till here .i think from here i need help.how can i make the computer to switch between the connections?Can any body give me any suggestions or links regarding this?
Thanking You
|
|
|
|
|
Hi,
im using propertygrid and trying to show boolean property with other string values than true/false,
i made boolenconverter for this, it works fine when i use combobox to change value, but i get inner propertygrid error when i doubleclick to change value in propertygrid:
Invalid property value!
Details: Cannot widen from target type to primitive type.
<br />
public class BaseProps{<br />
<br />
private bool test;<br />
<br />
[TypeConverter(typeof(BoolNameConverter2))]<br />
public bool Value {<br />
get {return test;}<br />
set {test = value;}<br />
}<br />
<br />
}<br />
<br />
<br />
public class BoolNameConverter2 : StringConverter<br />
{<br />
<br />
private const string m_trueDisplayName = "on";<br />
private const string m_falseDisplayName = "off";<br />
<br />
public override bool CanConvertTo(ITypeDescriptorContext context,<br />
System.Type destinationType) <br />
{<br />
if (destinationType == typeof(bool))<br />
return true;<br />
<br />
return base.CanConvertTo(context, destinationType);<br />
}<br />
<br />
public override object ConvertTo(ITypeDescriptorContext context,<br />
CultureInfo culture, <br />
object value, <br />
System.Type destinationType) <br />
{<br />
if (value is bool && destinationType == typeof(System.String)) {<br />
return (bool)value ? m_trueDisplayName : m_falseDisplayName;<br />
}<br />
return base.ConvertTo(context, culture, value, destinationType);<br />
}<br />
<br />
public override bool CanConvertFrom(ITypeDescriptorContext context,<br />
System.Type sourceType) <br />
{<br />
if (sourceType == typeof(string))<br />
return true;<br />
<br />
return base.CanConvertFrom(context, sourceType);<br />
}<br />
<br />
public override object ConvertFrom(ITypeDescriptorContext context,<br />
CultureInfo culture, object value) <br />
{<br />
if (value is string) {<br />
return (string)value == m_trueDisplayName ? true : false;<br />
} <br />
return base.ConvertFrom(context, culture, value);<br />
}<br />
<br />
public override bool GetStandardValuesSupported(<br />
ITypeDescriptorContext context) <br />
{<br />
return true;<br />
}<br />
<br />
public override StandardValuesCollection<br />
GetStandardValues(ITypeDescriptorContext context) <br />
{<br />
return new StandardValuesCollection (new string[]{m_trueDisplayName, m_falseDisplayName});<br />
} <br />
<br />
public override bool GetStandardValuesExclusive(<br />
ITypeDescriptorContext context) <br />
{<br />
return true;<br />
}<br />
<br />
}<br />
<br />
What could be the problem? Has anybody had similar problem and has solution? How to fix it?
Thanks
Deglimmer
|
|
|
|
|
|
hi
in my app, i have two forms, in form1, i have a button and gridview and a public method as 'LoadData' as follow :
public void LoadData()<br />
{<br />
using (SqlConnection con = new SqlConnection("Data Source=server;Initial Catalog=northwind;User Id=sa;Password=1;"))<br />
{<br />
SqlCommand cmd = new SqlCommand("select * from customers", con);<br />
SqlDataReader dr;<br />
DataTable dt = new DataTable();<br />
con.Open();<br />
dr = cmd.ExecuteReader();<br />
dt.Load(dr);<br />
con.Close();<br />
this.gridControl1.DataSource = dt.DefaultView;<br />
}<br />
}
in button_click event, i show form2 as follow :
private void simpleButton1_Click(object sender, EventArgs e)<br />
{ <br />
Form2 frm = new Form2();<br />
frm.Show();<br />
}
in form2, i have only one button, i want when i click this button, create object from form1 and calling LoadData() method to fill gridView as follow :
private void simpleButton1_Click(object sender, EventArgs e)<br />
{<br />
Form1 frm = new Form1();<br />
frm.LoadData();<br />
}
but in runTime, when i click button in form2, gridView does not fill, i trace my app and i saw frm.LoadData() was correctly work but gridView does not fill, where does my problem and how to solve it ?
thanks
|
|
|
|
|
So you have: Form1 with Button 1 and Form2 with Button 2 - if you klick Button 1, a new Form2 window should appear and if you then click on Button 2 in it, the first form (Form1) shall Load the data right?
Ok you will have to do something like this:
in Form2 declare a public function SetForm1 - that sets an internal variable to an object of Form1, then in the first button click use:
<br />
Form2 frm = new Form2();<br />
frm.SetForm1(this);<br />
frm.Show();<br />
and in Buttonclick of Form2:
<br />
_form1Var.LoadData();<br />
The problem is simple: in your code you create a new Form1 object (that you will never see - you never use it's Show-method) and fire LoadData against this!
Bye the way: you should not interweave two forms in such a way - use events of public functions for such tasks.
|
|
|
|
|
thanks for reply,
my problem was solved.
regards
|
|
|
|
|
<br />
<br />
private Form1 _form1;<br />
public void SetForm1(Form1 obj)<br />
{ _form1 = obj; }<br />
<br />
Then you can use
_form1.LoadData()
inside your Button_Click - event
|
|
|
|
|
Hi
I need to write an IF statement which checks if a session contains a _
how would i go about doing this
thanks
|
|
|
|
|
Please don't post questions twice, your last post comes down to the same question and I answered it there.
Standards are great! Everybody should have one!
|
|
|
|
|
|
How to get the number of all elements in XML file using DOM?
|
|
|
|
|
Hi
I have the following code which checks what the last number is in a database field after the _ and then adds 1 to it. however i need to add an extra bit of code in to check if a number exisits there already as the field could be: xxxx~xxx_01 or it could just be xxxx~xxx without the underscore. if its the latter then it will need to start from 1 and incrment up from there adding an underscore to the field where as at the moment it checks if there is a 1 there already,
any suggestions?
hope this makes sense, comment if not
cheers
SqlCommand cmd17 = new SqlCommand(test0002, con2);
StringBuilder htmlStr_room_code2 = new StringBuilder("");
SqlDataReader reader2 = cmd17.ExecuteReader();
while (reader2.Read())
{
htmlStr_room_code2.Append(reader2["room_code"]);
}
lbtest2.Text = htmlStr_room_code2.ToString();
Session["sessiontest1"] = lbtest2.Text.ToString();
string db = Session["sessiontest1"].ToString(); // "jh00~pr11_01";
string[] split = db.Split('_');
string s_number = split[1];
int i_number = Int32.Parse(s_number);
i_number++;
s_number = i_number.ToString();
db = split[0] + "_" + s_number;
|
|
|
|
|
Once you have your db string you can use if(db.Contains("_")) and go from there.
Standards are great! Everybody should have one!
|
|
|
|
|
I am developing an windows application and i want that when system starts application automatically run.
I know that may be done by using windows services but i am unable to do that.......
So please help
|
|
|
|
|
The answer's on the first page I got when searching on
Google[^] :S.
Standards are great! Everybody should have one!
|
|
|
|
|
|
as you've got answers concering windwos services:
I don't think you want to write a service-app. (services shouldn't use GUIs! - aka forms etc.) - you just want to start the app on starup? - Well put a link into your autostart (startup whatever) - folder in your start-menu!
|
|
|
|
|
... or (if the service is unecessary) put the path to your app in the registry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Value name: Your App
Value Data: Your_App_Path
|
|
|
|