Click here to Skip to main content
15,905,136 members
Home / Discussions / C#
   

C#

 
GeneralString.replace("\","\\") never work Pin
cocoonwls18-Apr-08 3:06
cocoonwls18-Apr-08 3:06 
GeneralRe: String.replace("\","\\") never work Pin
Paddy Boyd18-Apr-08 3:08
Paddy Boyd18-Apr-08 3:08 
GeneralRe: String.replace("\","\\") never work Pin
phannon8618-Apr-08 3:19
professionalphannon8618-Apr-08 3:19 
GeneralOr just use @ Pin
Mircea Puiu18-Apr-08 3:35
Mircea Puiu18-Apr-08 3:35 
GeneralRe: String.replace("\","\\") never work Pin
cocoonwls18-Apr-08 3:35
cocoonwls18-Apr-08 3:35 
Question"Real-Time" Audio Manipulation of Microphone Input Pin
littleGiant18-Apr-08 2:11
littleGiant18-Apr-08 2:11 
GeneralLosing object dataGridViewRow.cell.tag after sort Pin
oracleConvert18-Apr-08 2:05
oracleConvert18-Apr-08 2:05 
QuestionHow to working with database, Strongly Typed ? Pin
hdv21218-Apr-08 1:30
hdv21218-Apr-08 1:30 
hi i want to get customers data from database as CustomerCollection class (strongly typed), and bind my dataGridView to my CustomerCollection object.
i defined Customer class as follow :
class Customer<br />
    {<br />
        private string customerID;<br />
        private string companyName;<br />
<br />
        public string CustomerID<br />
        {<br />
            get { return customerID; }<br />
            set { customerID = value; }<br />
        }        <br />
<br />
        public string CompanyName<br />
        {<br />
            get { return companyName; }<br />
            set { companyName = value; }<br />
        }<br />
<br />
        public Customer() { }<br />
<br />
        public Customer(string custID, string company)<br />
        {<br />
            this.CustomerID = custID;<br />
            this.CompanyName = company;<br />
        }<br />
<br />
        public DataTable GetCustomers()<br />
        {<br />
            DataAccess da = new DataAccess("Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=1");<br />
            DataTable dt = new DataTable();<br />
            da.ExecuteCommand(new SqlCommand("SELECT CustomerID,CompanyName FROM CUSTOMERS"),out dt);            <br />
            return dt;<br />
        }        <br />
    }


and defined CustomerCollection class as follow :
class CustomerCollection : System.Collections.CollectionBase<br />
    {<br />
        public CustomerCollection()<br />
        {<br />
<br />
        }<br />
<br />
        public void Add(Customer customer)<br />
        {<br />
            List.Add(customer);<br />
        }<br />
<br />
        public void Remove(Customer customer)<br />
        {<br />
            List.Remove(customer);<br />
        }<br />
<br />
        public Customer this[int index]<br />
        {<br />
            get<br />
            {<br />
                return (Customer)List[index];<br />
            }<br />
<br />
            set<br />
            {<br />
                base.List[index] = value;<br />
            }<br />
        }<br />
    }


but i don't know when i use this code :
Customer c = new Customer();<br />
this.dataGridView1.DataSource = c.GetCustomers();

how to bind my datagridView to my strongly typed collection object (CustomerCollection), how to do ?
thanks
AnswerRe: How to working with database, Strongly Typed ? Pin
Pete O'Hanlon18-Apr-08 2:33
mvePete O'Hanlon18-Apr-08 2:33 
GeneralRe: How to working with database, Strongly Typed ? Pin
hdv21218-Apr-08 3:37
hdv21218-Apr-08 3:37 
GeneralRe: How to working with database, Strongly Typed ? Pin
ChrisKo18-Apr-08 5:10
ChrisKo18-Apr-08 5:10 
GeneralRe: How to working with database, Strongly Typed ? Pin
hdv21218-Apr-08 6:36
hdv21218-Apr-08 6:36 
GeneralSqlConnection, extract server & database values Pin
laserbaronen18-Apr-08 1:04
laserbaronen18-Apr-08 1:04 
AnswerRe: SqlConnection, extract server & database values [SOLVED] Pin
laserbaronen18-Apr-08 1:10
laserbaronen18-Apr-08 1:10 
GeneralUnkown abt return type Pin
EvilInside18-Apr-08 0:27
EvilInside18-Apr-08 0:27 
GeneralRe: Unkown abt return type Pin
Christian Graus18-Apr-08 0:32
protectorChristian Graus18-Apr-08 0:32 
QuestionDataAdapter.Update method ?? Pin
Hum Dum18-Apr-08 0:24
Hum Dum18-Apr-08 0:24 
AnswerRe: DataAdapter.Update method ?? Pin
J4amieC18-Apr-08 1:03
J4amieC18-Apr-08 1:03 
QuestionDo you know a good thumbnail component? Pin
Yianni18-Apr-08 0:21
Yianni18-Apr-08 0:21 
Generalhelp with variance and gradients of pixels Pin
diddy3417-Apr-08 23:29
diddy3417-Apr-08 23:29 
GeneralRe: help with variance and gradients of pixels Pin
Christian Graus18-Apr-08 0:33
protectorChristian Graus18-Apr-08 0:33 
QuestionRunning windows form remotely Pin
ONeil Tomlinson17-Apr-08 22:49
ONeil Tomlinson17-Apr-08 22:49 
GeneralRe: Running windows form remotely Pin
darkelv17-Apr-08 23:58
darkelv17-Apr-08 23:58 
GeneralRe: Running windows form remotely Pin
ONeil Tomlinson18-Apr-08 2:13
ONeil Tomlinson18-Apr-08 2:13 
GeneralOledbDataAdapter.fill gives a blank line when used to import some excel files Pin
Rey999917-Apr-08 22:32
Rey999917-Apr-08 22:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.