|
i m working with access database at the back end and using C#.net programming
i want to store the multiple selected items from the listbox to the access database in a single column
plzzzz can anyone help me
i need reply sooon!!!!!!
i m a new learner in C#.net
thnx in advance
|
|
|
|
|
Loop in all items of Listbox and while looping get only selected items.
e.g.
StringBuilder sb = new StringBuilder();<br />
for (int i=0;i<=listBox1.Items.Count-1;i++)<br />
{<br />
if (listBox1.GetSelected(i) == true)<br />
{<br />
sb.Append(listBox1.Items[i].ToString());<br />
sb.Append(",");<br />
}<br />
}<br />
string values = sb.ToString();
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
i m getting error
Error 1 : The type or namespace name 'StringBuilder' could not be found (are you missing a using directive or an assembly reference?)
how to declare this name space??
|
|
|
|
|
Include using namespace System.Text on top of class,or use System.Text.StringBuilder sb = new System.Text.StringBuilder();
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Hi,
I would like to know how can I refer to array such as byte array with offset
such as I would like to use the array from spesific location till the array end
in c++ i would do somthing like that
char *samplesBuffer
int offset = 20;
funcName(samplesBuffer+offset)
how can I do int in c#
thanks
ronen
|
|
|
|
|
You can't. C# doesn't support that sort of pointer arithmetic. You'd have to pass in the starting index instead. The good news is, the array knows it's length, in C++ you'd still have to pass in a length so you knew how far you could go in it
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
how to Consume java written webservices without adding reference in c#
|
|
|
|
|
Prayer, I guess.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
I have a project from the university to implement the fax protocol (in any language I want).
The idea is to write a software that will be able to receive a fax from a real fax machine. It can be done in any way I want - any language/environment , via modem or some other idea.
I know how the fax protocol works and I wrote a simple implementation already. The problem is actually running it.
I tried writing a C# program using SerialPort class and to access the modem's received data. The problem is that the modem does its own thing upon connecting and doesn't give me control over the received data.
I ran out of ideas at this point.
What else can I do?
Thank you very much.
|
|
|
|
|
I am selecting a value,group_id,from the database table-group,using a datareader.Then i am assigning the result to the variable str_group.
But why is it giving the message'use of unassigned variable str_group???????My code is like this
string str_group;
OleDbCommand cmd1 = new OleDbCommand("select Group_id from Group_details where group='" + descriptiondpdwnlist.SelectedItem + "'",con1);
dr = cmd1.ExecuteReader();
while (dr.Read ())
{
str_group = (string)dr[0];
}
string cmd2 = "select description from description_details where group_id='"+str_group +"'";
|
|
|
|
|
myinstincts wrote: string str_group;
string str_group = string.Empty;
|
|
|
|
|
Hey ma friends,
I wanted to make my controls(lets say button1)to be circular @ run time ..... like the play button in media player or other players ....... I tried to make it in the button1_Paint() event
but it doesnt work ...... How could I do that ..... Please help me.....
Thank you.
|
|
|
|
|
|
Hi ..
I am stuck with issue & don’t seem to find a way around.
I have an excel sheet which I am reading in my C# windows application . I read values form F column to V column. I collect this in a string array & then display the values of the array to user.
The problem is in differentiating the dates & the number values .. here is the problem I faced:
I have 2 cells ..1st one has value 40524 & the 2nd has 12/12/2010. When I get the values both of them are returned as 40524 !! So how do you determine programmatically which cell actually was meant for numbers & which was for date because if I have to display the contents of a row (without knowing the format) I want to show 12/12/2010 as 12/12/2010 & not as 40524.
I am using the following code to get values from Excel
Range vrange = worksheet.get_Range("F" + i.ToString(), "V" + i.ToString());
System.Array vmyvalues = (System.Array)vrange.Cells.Value2;
string [] ret = ConvertToStringArray(vmyvalues);
As you can see i am getting values from column F to V & when I iterate through the above string array "ret" I can see the value as of 12/12/2010 as 40524 where as I need it as is shown by excel
Thanks for help.
Suunil
|
|
|
|
|
You are getting an implicit conversion to a julian date, you will need to get at the data type of the column rather than just the value.
|
|
|
|
|
& how do I do that? do you have a code snippet ?? I am new to excel programming
|
|
|
|
|
Sorry, I don't work with excel, you need to inspect the properties of the cell you are working with, look for a datatype or possibly format keyword.
|
|
|
|
|
Is there any Way to have some Comments in Right to Left Languages
If there is please tell me
|
|
|
|
|
I want to have a custom configuration . I implement Test class as follow:
public sealed class Test : ConfigurationSection
{
private static ConfigurationPropertyCollection _Properties;
private static readonly ConfigurationProperty _ID =
new ConfigurationProperty("ID", typeof(string),"1");
private static readonly ConfigurationProperty _status =
new ConfigurationProperty("status", typeof(string), "1");
private static readonly ConfigurationProperty _color =
new ConfigurationProperty("color", typeof(string), "1");
public Test()
{
// Property initialization
_Properties =
new ConfigurationPropertyCollection();
_Properties.Add(_ID);
_Properties.Add(_status);
_Properties.Add(_color);
}
protected override ConfigurationPropertyCollection Properties
{
get
{
return _Properties;
}
}
[StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"|\\GHIJKLMNOPQRSTUVWXYZ", MinLength = 6, MaxLength = 6)]
public string ID
{
get
{
return (string)this["ID"];
}
set
{
this["ID"] = value;
}
}
[StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"|\\GHIJKLMNOPQRSTUVWXYZ", MinLength = 6, MaxLength = 6)]
public string status
{
get
{
return (string)this["status"];
}
set
{
this["status"] = value;
}
}
[StringValidator(InvalidCharacters = "~!@#$%^&*()[]{}/;'\"|\\GHIJKLMNOPQRSTUVWXYZ", MinLength = 6, MaxLength = 6)]
public string color
{
get
{
return (string)this["color"];
}
set
{
this["color"] = value;
}
}
}
To retrieve my custom setting data the using code is as follow. Config can recognize "mySection" but the myConfig is always null. How can I solve this problem.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None) as Configuration;
Test myConfig = new Test();
myConfig = config.GetSection("mySection") as Test;
<configuration>
<configsections>
< mySection >
<add key="ID" value="1">;
<add key="status" value="f">;
<add key="color" value="f">;
tahereh sadeghi
|
|
|
|
|
I'm sure this is a very noobish question and the answer will be obvious once I get it although here it is...
I have created a class that inherits from BindingList<t> and I'm trying to enable the FindCore method. The code is below:
public class AccountList : BindingList<Account>
{
protected override bool SupportsSearchingCore
{
get
{
return true;
}
}
protected override int FindCore(PropertyDescriptor prop, object key)
{
for (int i = 0; i < Count; ++i)
{
if (Items[i].AccountName.ToLower() == ((string)key).ToLower())
return i;
}
return -1;
}
When I create and instance of "AccountList" I don't have access to the FindCore method the IDE says "inaccessable due to it's protection level".
My guess is there is something that I don't understand about the implementation of this method. I've only been working with .NET for about 6 weeks so please excuse my noobish question.
Thanks!
|
|
|
|
|
If you are creating the instance outside AccountList class, you wont be able to access the method since it is protected.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
If thats the case how am I supposed to access the method? I cant access like it was static either.
I'm thinking that I was also supposed to implement an interface and not just override the method, is that the case? The documentation is very vague here.
|
|
|
|
|
Dear,
I start programming a very small project called "CD Collection" for my self learning which is using C Sharp 2005 and MS Access 2007. I would love you to instruct me if possible. I can insert into table (eg: tbl_user (uID, username)) normally but I've no idea how to load these data to combobox (in other form - tbl_cd (cd_id, music_code, uID, cd_set_id)). So, what do I've to code?
1. How to load data from db to combobox?
2. After successfully loaded, I want to know how do I insert uID(from combobox) back to uID in tbl_cd?
Many thanks,
Chuon Visoth
Angkor Wat - Cambodia
asp.net - c sharp beginner
|
|
|
|
|
If you set the datasource of the combobox to be the dataset you get back from the DB, you set the displaymember property to set which column the combobox should show.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|