Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
QuestionPublishing a console application? Pin
Goalie3529-Jul-08 4:14
Goalie3529-Jul-08 4:14 
AnswerRe: Publishing a console application? Pin
leppie29-Jul-08 4:48
leppie29-Jul-08 4:48 
AnswerRe: Publishing a console application? Pin
Mircea Puiu29-Jul-08 4:58
Mircea Puiu29-Jul-08 4:58 
QuestionMultiThread Programing Pin
LincolnGuimaraes29-Jul-08 3:58
LincolnGuimaraes29-Jul-08 3:58 
AnswerRe: MultiThread Programing Pin
Mircea Puiu29-Jul-08 4:47
Mircea Puiu29-Jul-08 4:47 
AnswerRe: MultiThread Programing Pin
Yosh_29-Jul-08 5:00
professionalYosh_29-Jul-08 5:00 
AnswerRe: MultiThread Programing Pin
Yosh_29-Jul-08 5:01
professionalYosh_29-Jul-08 5:01 
AnswerRe: MultiThread Programing Pin
Guffa29-Jul-08 6:34
Guffa29-Jul-08 6:34 
AnswerRe: MultiThread Programing Pin
Joe Woodbury29-Jul-08 9:24
professionalJoe Woodbury29-Jul-08 9:24 
Questionjavascript for grid view checkbox Pin
umeshdaiya29-Jul-08 3:14
umeshdaiya29-Jul-08 3:14 
AnswerRe: javascript for grid view checkbox Pin
leppie29-Jul-08 4:51
leppie29-Jul-08 4:51 
QuestionCannot pass params! Any ideas? Pin
FruitBatInShades29-Jul-08 2:56
FruitBatInShades29-Jul-08 2:56 
AnswerRe: Cannot pass params! Any ideas? Pin
J4amieC29-Jul-08 3:00
J4amieC29-Jul-08 3:00 
GeneralRe: Cannot pass params! Any ideas? Pin
Luc Pattyn29-Jul-08 4:00
sitebuilderLuc Pattyn29-Jul-08 4:00 
GeneralRe: Cannot pass params! Any ideas? Pin
J4amieC29-Jul-08 4:27
J4amieC29-Jul-08 4:27 
GeneralRe: Cannot pass params! Any ideas? Pin
FruitBatInShades29-Jul-08 22:47
FruitBatInShades29-Jul-08 22:47 
QuestionRe: Cannot pass params! Any ideas? Pin
Luc Pattyn29-Jul-08 3:11
sitebuilderLuc Pattyn29-Jul-08 3:11 
QuestionHttp traffic from IE Pin
George_George29-Jul-08 2:31
George_George29-Jul-08 2:31 
AnswerRe: Http traffic from IE Pin
J4amieC29-Jul-08 2:45
J4amieC29-Jul-08 2:45 
GeneralRe: Http traffic from IE Pin
George_George29-Jul-08 3:15
George_George29-Jul-08 3:15 
QuestionDynamically Add Columns to Existing DataTable Pin
MumbleB29-Jul-08 2:20
MumbleB29-Jul-08 2:20 
AnswerRe: Dynamically Add Columns to Existing DataTable [modified] Pin
paas29-Jul-08 3:02
paas29-Jul-08 3:02 
GeneralRe: Dynamically Add Columns to Existing DataTable Pin
MumbleB29-Jul-08 3:08
MumbleB29-Jul-08 3:08 
GeneralRe: Dynamically Add Columns to Existing DataTable Pin
paas29-Jul-08 3:10
paas29-Jul-08 3:10 
AnswerRe: Dynamically Add Columns to Existing DataTable [modified] Pin
Tuwing.Sabado29-Jul-08 3:07
Tuwing.Sabado29-Jul-08 3:07 
Hi,

These are my review points.

1. You don't have a variable for DataAdapter.
2. What is the purpose of the DataAdapater if your codes are not filling this.
3. You don't have a columnName and data Type for dMember Variable.
4. Opening and Closing of Connection are not necessary for DataAdapter. Data
Adapter will automatically do this for you.

Here are the correct codes.


conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source = T:\Nasmeea\PSSZ.mdb";
conn.Open(); // This is Optional because DataAdapter will automatically open the given connection.
DataAdapter da = new DataAdapter("Select field1, field2 From [DivInfo]", conn);
DataTable dataTable = new DataTable("System_Setting"); // Creating Untype Datatable. Expected count of fields are 2.
da.Fill(dataTable); // Fill the datatable

//Adding two fields.
DataColumn dValue = new DataColumn();
DataColumn dMember = new DataColumn();
dValue.ColumnName = "dValue";
dValue.DataType = Type.GetType("System.String");
dMember.ColumnName = "dMember";
dMember.DataType = Type.GetType("System.String");
dataTable.Columns.Add(dValue);
dataTable.Columns.Add(dMember);
conn.Close(); // This is Optional because DataAdapter will automatically close the given connection.

MessageBox.Show("Column Count:" + dataTable.Columns.Count.ToString());
MessageBox.Show("Row Count:" + dataTable.Rows.Count.ToString());



Regards,

modified on Tuesday, July 29, 2008 9:26 AM

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.