PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average.

puzzle question 2

 
 
maiyude
Guest
Posts: n/a
 
      5th Feb 2009


public partial class Insert : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strCon = "Data Source=localhost;Initial
Catalog=pubs;Integrated Security=True;User ID =sa;Password =sa";
SqlConnection myConnection = new SqlConnection(strCon);
// myConnection.Open();

SqlCommand myCommand = new SqlCommand("select * from authors",
myConnection);
//

///puzzle 1 begin
//begin *
SqlCommand sqlInsertCommand1 = new SqlCommand();
sqlInsertCommand1.CommandText = @"INSERT INTO authors(au_id,
au_lname, au_fname, phone, address, city, state, zip, contract)
VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state, @zip,
@contract);
SELECT au_id, au_lname, au_fname, phone, address, city, state, zip, contract
FROM authors WHERE (au_id = @au_id)";
sqlInsertCommand1.Connection = myConnection;


sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_id",
System.Data.SqlDbType.VarChar, 11, "au_id"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_lname",
System.Data.SqlDbType.VarChar, 40, "au_lname"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_fname",
System.Data.SqlDbType.VarChar, 20, "au_fname"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@phone",
System.Data.SqlDbType.VarChar, 12, "phone"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@address",
System.Data.SqlDbType.VarChar, 40, "address"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@city",
System.Data.SqlDbType.VarChar, 20, "city"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@state",
System.Data.SqlDbType.VarChar, 2, "state"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@zip",
System.Data.SqlDbType.VarChar, 5, "zip"));
sqlInsertCommand1.Parameters.Add(new SqlParameter("@contract",
System.Data.SqlDbType.Bit, 1, "contract"));

//end *
SqlDataAdapter Adapter = new SqlDataAdapter();
Adapter.SelectCommand = myCommand;
Adapter.InsertCommand = sqlInsertCommand1;//if begin* and end*'s
codes is omitted, this line should be omitted too?

DataSet myDs = new DataSet();
Adapter.Fill(myDs);

//
DataTable myTable = myDs.Tables[0];
//
DataRow myRow = myTable.NewRow();
//
myRow["au_id"] = "322-22-2222";
myRow["au_lname"] = "Li";
myRow["au_fname"] = "Paul";
myRow["phone"] = "12345678";
myRow["city"] = "Chengdu";
myRow["contract"] = 1;

//
myTable.Rows.Add(myRow);

//
Adapter.Update(myDs);

//
myConnection.Close();
myConnection.Open();
Adapter.Fill(myDs);
///it seems that there is no use for the codes between begin* and
end*? Because i found there is no Insertcommand
///below except the Adapter.InsertCommand = sqlInsertCommand1?
///what codes would call the function of the Adapter.InsertCommand?
///puzzle1 end


//
Response.Write("<h3>Insert Data</h3><hr>");
Response.Write("<table border=1 cellspacing=0 cellpadding=2>");

//
Response.Write("<tr bgcolor=#DAB4B4>");
foreach (DataColumn myColumn in myTable.Columns)
{
Response.Write("<td>" + myColumn.ColumnName + "</td>");
}

Response.Write("</tr>");

//
foreach (DataRow row in myTable.Rows)
{
if (row["au_id"].ToString() == "322-22-2222")
{
Response.Write("<tr>");
foreach (DataColumn myColumn in myTable.Columns)
{
Response.Write("<td>" + row[myColumn] + "</td>");
}
Response.Write("</tr>");
break;
}
}
Response.Write("</table>");

myConnection.Close();
}

}



 
Reply With Quote
 
 
 
 
William Vaughn \(MVP\)
Guest
Posts: n/a
 
      5th Feb 2009
All of these questions (and I expect a lot more) are answered in my book.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________



"maiyude" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> public partial class Insert : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> string strCon = "Data Source=localhost;Initial
> Catalog=pubs;Integrated Security=True;User ID =sa;Password =sa";
> SqlConnection myConnection = new SqlConnection(strCon);
> // myConnection.Open();
>
> SqlCommand myCommand = new SqlCommand("select * from authors",
> myConnection);
> //
>
> ///puzzle 1 begin
> //begin *
> SqlCommand sqlInsertCommand1 = new SqlCommand();
> sqlInsertCommand1.CommandText = @"INSERT INTO authors(au_id,
> au_lname, au_fname, phone, address, city, state, zip, contract)
> VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state,
> @zip,
> @contract);
> SELECT au_id, au_lname, au_fname, phone, address, city, state, zip,
> contract
> FROM authors WHERE (au_id = @au_id)";
> sqlInsertCommand1.Connection = myConnection;
>
>
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_id",
> System.Data.SqlDbType.VarChar, 11, "au_id"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_lname",
> System.Data.SqlDbType.VarChar, 40, "au_lname"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_fname",
> System.Data.SqlDbType.VarChar, 20, "au_fname"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@phone",
> System.Data.SqlDbType.VarChar, 12, "phone"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@address",
> System.Data.SqlDbType.VarChar, 40, "address"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@city",
> System.Data.SqlDbType.VarChar, 20, "city"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@state",
> System.Data.SqlDbType.VarChar, 2, "state"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@zip",
> System.Data.SqlDbType.VarChar, 5, "zip"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@contract",
> System.Data.SqlDbType.Bit, 1, "contract"));
>
> //end *
> SqlDataAdapter Adapter = new SqlDataAdapter();
> Adapter.SelectCommand = myCommand;
> Adapter.InsertCommand = sqlInsertCommand1;//if begin* and end*'s
> codes is omitted, this line should be omitted too?
>
> DataSet myDs = new DataSet();
> Adapter.Fill(myDs);
>
> //
> DataTable myTable = myDs.Tables[0];
> //
> DataRow myRow = myTable.NewRow();
> //
> myRow["au_id"] = "322-22-2222";
> myRow["au_lname"] = "Li";
> myRow["au_fname"] = "Paul";
> myRow["phone"] = "12345678";
> myRow["city"] = "Chengdu";
> myRow["contract"] = 1;
>
> //
> myTable.Rows.Add(myRow);
>
> //
> Adapter.Update(myDs);
>
> //
> myConnection.Close();
> myConnection.Open();
> Adapter.Fill(myDs);
> ///it seems that there is no use for the codes between begin* and
> end*? Because i found there is no Insertcommand
> ///below except the Adapter.InsertCommand = sqlInsertCommand1?
> ///what codes would call the function of the Adapter.InsertCommand?
> ///puzzle1 end
>
>
> //
> Response.Write("<h3>Insert Data</h3><hr>");
> Response.Write("<table border=1 cellspacing=0 cellpadding=2>");
>
> //
> Response.Write("<tr bgcolor=#DAB4B4>");
> foreach (DataColumn myColumn in myTable.Columns)
> {
> Response.Write("<td>" + myColumn.ColumnName + "</td>");
> }
>
> Response.Write("</tr>");
>
> //
> foreach (DataRow row in myTable.Rows)
> {
> if (row["au_id"].ToString() == "322-22-2222")
> {
> Response.Write("<tr>");
> foreach (DataColumn myColumn in myTable.Columns)
> {
> Response.Write("<td>" + row[myColumn] + "</td>");
> }
> Response.Write("</tr>");
> break;
> }
> }
> Response.Write("</table>");
>
> myConnection.Close();
> }
>
> }
>
>
>

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      5th Feb 2009
I am missing the question.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************

"maiyude" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>
> public partial class Insert : System.Web.UI.Page
> {
> protected void Page_Load(object sender, EventArgs e)
> {
> string strCon = "Data Source=localhost;Initial
> Catalog=pubs;Integrated Security=True;User ID =sa;Password =sa";
> SqlConnection myConnection = new SqlConnection(strCon);
> // myConnection.Open();
>
> SqlCommand myCommand = new SqlCommand("select * from authors",
> myConnection);
> //
>
> ///puzzle 1 begin
> //begin *
> SqlCommand sqlInsertCommand1 = new SqlCommand();
> sqlInsertCommand1.CommandText = @"INSERT INTO authors(au_id,
> au_lname, au_fname, phone, address, city, state, zip, contract)
> VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state,
> @zip,
> @contract);
> SELECT au_id, au_lname, au_fname, phone, address, city, state, zip,
> contract
> FROM authors WHERE (au_id = @au_id)";
> sqlInsertCommand1.Connection = myConnection;
>
>
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_id",
> System.Data.SqlDbType.VarChar, 11, "au_id"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_lname",
> System.Data.SqlDbType.VarChar, 40, "au_lname"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_fname",
> System.Data.SqlDbType.VarChar, 20, "au_fname"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@phone",
> System.Data.SqlDbType.VarChar, 12, "phone"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@address",
> System.Data.SqlDbType.VarChar, 40, "address"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@city",
> System.Data.SqlDbType.VarChar, 20, "city"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@state",
> System.Data.SqlDbType.VarChar, 2, "state"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@zip",
> System.Data.SqlDbType.VarChar, 5, "zip"));
> sqlInsertCommand1.Parameters.Add(new SqlParameter("@contract",
> System.Data.SqlDbType.Bit, 1, "contract"));
>
> //end *
> SqlDataAdapter Adapter = new SqlDataAdapter();
> Adapter.SelectCommand = myCommand;
> Adapter.InsertCommand = sqlInsertCommand1;//if begin* and end*'s
> codes is omitted, this line should be omitted too?
>
> DataSet myDs = new DataSet();
> Adapter.Fill(myDs);
>
> //
> DataTable myTable = myDs.Tables[0];
> //
> DataRow myRow = myTable.NewRow();
> //
> myRow["au_id"] = "322-22-2222";
> myRow["au_lname"] = "Li";
> myRow["au_fname"] = "Paul";
> myRow["phone"] = "12345678";
> myRow["city"] = "Chengdu";
> myRow["contract"] = 1;
>
> //
> myTable.Rows.Add(myRow);
>
> //
> Adapter.Update(myDs);
>
> //
> myConnection.Close();
> myConnection.Open();
> Adapter.Fill(myDs);
> ///it seems that there is no use for the codes between begin* and
> end*? Because i found there is no Insertcommand
> ///below except the Adapter.InsertCommand = sqlInsertCommand1?
> ///what codes would call the function of the Adapter.InsertCommand?
> ///puzzle1 end
>
>
> //
> Response.Write("<h3>Insert Data</h3><hr>");
> Response.Write("<table border=1 cellspacing=0 cellpadding=2>");
>
> //
> Response.Write("<tr bgcolor=#DAB4B4>");
> foreach (DataColumn myColumn in myTable.Columns)
> {
> Response.Write("<td>" + myColumn.ColumnName + "</td>");
> }
>
> Response.Write("</tr>");
>
> //
> foreach (DataRow row in myTable.Rows)
> {
> if (row["au_id"].ToString() == "322-22-2222")
> {
> Response.Write("<tr>");
> foreach (DataColumn myColumn in myTable.Columns)
> {
> Response.Write("<td>" + row[myColumn] + "</td>");
> }
> Response.Write("</tr>");
> break;
> }
> }
> Response.Write("</table>");
>
> myConnection.Close();
> }
>
> }
>
>
>

 
Reply With Quote
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      6th Feb 2009
Gregory,

Rofl

>I am missing the question.
>
> --

They are all answered in the book from Bill.

Cor

 
Reply With Quote
 
maiyude
Guest
Posts: n/a
 
      6th Feb 2009
thank you
then what is the book's name?where to buy or download?


"William Vaughn (MVP)" <(E-Mail Removed)>
??????:(E-Mail Removed)...
> All of these questions (and I expect a lot more) are answered in my book.
>
> --
> __________________________________________________________________________
> William R. Vaughn
> President and Founder Beta V Corporation
> Author, Mentor, Dad, Grandpa
> Microsoft MVP
> (425) 556-9205 (Pacific time)
> Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
> http://betav.com http://betav.com/blog/billva
> ____________________________________________________________________________________________
>
>
>
> "maiyude" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>
>>
>> public partial class Insert : System.Web.UI.Page
>> {
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> string strCon = "Data Source=localhost;Initial
>> Catalog=pubs;Integrated Security=True;User ID =sa;Password =sa";
>> SqlConnection myConnection = new SqlConnection(strCon);
>> // myConnection.Open();
>>
>> SqlCommand myCommand = new SqlCommand("select * from authors",
>> myConnection);
>> //
>>
>> ///puzzle 1 begin
>> //begin *
>> SqlCommand sqlInsertCommand1 = new SqlCommand();
>> sqlInsertCommand1.CommandText = @"INSERT INTO authors(au_id,
>> au_lname, au_fname, phone, address, city, state, zip, contract)
>> VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state,
>> @zip,
>> @contract);
>> SELECT au_id, au_lname, au_fname, phone, address, city, state, zip,
>> contract
>> FROM authors WHERE (au_id = @au_id)";
>> sqlInsertCommand1.Connection = myConnection;
>>
>>
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_id",
>> System.Data.SqlDbType.VarChar, 11, "au_id"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_lname",
>> System.Data.SqlDbType.VarChar, 40, "au_lname"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_fname",
>> System.Data.SqlDbType.VarChar, 20, "au_fname"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@phone",
>> System.Data.SqlDbType.VarChar, 12, "phone"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@address",
>> System.Data.SqlDbType.VarChar, 40, "address"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@city",
>> System.Data.SqlDbType.VarChar, 20, "city"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@state",
>> System.Data.SqlDbType.VarChar, 2, "state"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@zip",
>> System.Data.SqlDbType.VarChar, 5, "zip"));
>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@contract",
>> System.Data.SqlDbType.Bit, 1, "contract"));
>>
>> //end *
>> SqlDataAdapter Adapter = new SqlDataAdapter();
>> Adapter.SelectCommand = myCommand;
>> Adapter.InsertCommand = sqlInsertCommand1;//if begin* and end*'s
>> codes is omitted, this line should be omitted too?
>>
>> DataSet myDs = new DataSet();
>> Adapter.Fill(myDs);
>>
>> //
>> DataTable myTable = myDs.Tables[0];
>> //
>> DataRow myRow = myTable.NewRow();
>> //
>> myRow["au_id"] = "322-22-2222";
>> myRow["au_lname"] = "Li";
>> myRow["au_fname"] = "Paul";
>> myRow["phone"] = "12345678";
>> myRow["city"] = "Chengdu";
>> myRow["contract"] = 1;
>>
>> //
>> myTable.Rows.Add(myRow);
>>
>> //
>> Adapter.Update(myDs);
>>
>> //
>> myConnection.Close();
>> myConnection.Open();
>> Adapter.Fill(myDs);
>> ///it seems that there is no use for the codes between begin* and
>> end*? Because i found there is no Insertcommand
>> ///below except the Adapter.InsertCommand = sqlInsertCommand1?
>> ///what codes would call the function of the
>> Adapter.InsertCommand?
>> ///puzzle1 end
>>
>>
>> //
>> Response.Write("<h3>Insert Data</h3><hr>");
>> Response.Write("<table border=1 cellspacing=0 cellpadding=2>");
>>
>> //
>> Response.Write("<tr bgcolor=#DAB4B4>");
>> foreach (DataColumn myColumn in myTable.Columns)
>> {
>> Response.Write("<td>" + myColumn.ColumnName + "</td>");
>> }
>>
>> Response.Write("</tr>");
>>
>> //
>> foreach (DataRow row in myTable.Rows)
>> {
>> if (row["au_id"].ToString() == "322-22-2222")
>> {
>> Response.Write("<tr>");
>> foreach (DataColumn myColumn in myTable.Columns)
>> {
>> Response.Write("<td>" + row[myColumn] + "</td>");
>> }
>> Response.Write("</tr>");
>> break;
>> }
>> }
>> Response.Write("</table>");
>>
>> myConnection.Close();
>> }
>>
>> }
>>
>>
>>



 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      7th Feb 2009
I just figured the person wanted me to pour through code and fix it, but I
saw no question. Good to know it is Bill's book. :-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*********************************************
| Think outside the box |
*********************************************
"Cor Ligthert[MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Gregory,
>
> Rofl
>
>>I am missing the question.
>>
>> --

> They are all answered in the book from Bill.
>
> Cor
>


 
Reply With Quote
 
William Vaughn \(MVP\)
Guest
Posts: n/a
 
      8th Feb 2009
See my sig or website (as shown below).

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
http://betav.com http://betav.com/blog/billva
____________________________________________________________________________________________



"maiyude" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> thank you
> then what is the book's name?where to buy or download?
>
>
> "William Vaughn (MVP)" <(E-Mail Removed)>
> ??????:(E-Mail Removed)...
>> All of these questions (and I expect a lot more) are answered in my book.
>>
>> --
>> __________________________________________________________________________
>> William R. Vaughn
>> President and Founder Beta V Corporation
>> Author, Mentor, Dad, Grandpa
>> Microsoft MVP
>> (425) 556-9205 (Pacific time)
>> Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
>> http://betav.com http://betav.com/blog/billva
>> ____________________________________________________________________________________________
>>
>>
>>
>> "maiyude" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>
>>>
>>> public partial class Insert : System.Web.UI.Page
>>> {
>>> protected void Page_Load(object sender, EventArgs e)
>>> {
>>> string strCon = "Data Source=localhost;Initial
>>> Catalog=pubs;Integrated Security=True;User ID =sa;Password =sa";
>>> SqlConnection myConnection = new SqlConnection(strCon);
>>> // myConnection.Open();
>>>
>>> SqlCommand myCommand = new SqlCommand("select * from authors",
>>> myConnection);
>>> //
>>>
>>> ///puzzle 1 begin
>>> //begin *
>>> SqlCommand sqlInsertCommand1 = new SqlCommand();
>>> sqlInsertCommand1.CommandText = @"INSERT INTO authors(au_id,
>>> au_lname, au_fname, phone, address, city, state, zip, contract)
>>> VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state,
>>> @zip,
>>> @contract);
>>> SELECT au_id, au_lname, au_fname, phone, address, city, state, zip,
>>> contract
>>> FROM authors WHERE (au_id = @au_id)";
>>> sqlInsertCommand1.Connection = myConnection;
>>>
>>>
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_id",
>>> System.Data.SqlDbType.VarChar, 11, "au_id"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_lname",
>>> System.Data.SqlDbType.VarChar, 40, "au_lname"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@au_fname",
>>> System.Data.SqlDbType.VarChar, 20, "au_fname"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@phone",
>>> System.Data.SqlDbType.VarChar, 12, "phone"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@address",
>>> System.Data.SqlDbType.VarChar, 40, "address"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@city",
>>> System.Data.SqlDbType.VarChar, 20, "city"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@state",
>>> System.Data.SqlDbType.VarChar, 2, "state"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@zip",
>>> System.Data.SqlDbType.VarChar, 5, "zip"));
>>> sqlInsertCommand1.Parameters.Add(new SqlParameter("@contract",
>>> System.Data.SqlDbType.Bit, 1, "contract"));
>>>
>>> //end *
>>> SqlDataAdapter Adapter = new SqlDataAdapter();
>>> Adapter.SelectCommand = myCommand;
>>> Adapter.InsertCommand = sqlInsertCommand1;//if begin* and end*'s
>>> codes is omitted, this line should be omitted too?
>>>
>>> DataSet myDs = new DataSet();
>>> Adapter.Fill(myDs);
>>>
>>> //
>>> DataTable myTable = myDs.Tables[0];
>>> //
>>> DataRow myRow = myTable.NewRow();
>>> //
>>> myRow["au_id"] = "322-22-2222";
>>> myRow["au_lname"] = "Li";
>>> myRow["au_fname"] = "Paul";
>>> myRow["phone"] = "12345678";
>>> myRow["city"] = "Chengdu";
>>> myRow["contract"] = 1;
>>>
>>> //
>>> myTable.Rows.Add(myRow);
>>>
>>> //
>>> Adapter.Update(myDs);
>>>
>>> //
>>> myConnection.Close();
>>> myConnection.Open();
>>> Adapter.Fill(myDs);
>>> ///it seems that there is no use for the codes between begin* and
>>> end*? Because i found there is no Insertcommand
>>> ///below except the Adapter.InsertCommand = sqlInsertCommand1?
>>> ///what codes would call the function of the
>>> Adapter.InsertCommand?
>>> ///puzzle1 end
>>>
>>>
>>> //
>>> Response.Write("<h3>Insert Data</h3><hr>");
>>> Response.Write("<table border=1 cellspacing=0 cellpadding=2>");
>>>
>>> //
>>> Response.Write("<tr bgcolor=#DAB4B4>");
>>> foreach (DataColumn myColumn in myTable.Columns)
>>> {
>>> Response.Write("<td>" + myColumn.ColumnName + "</td>");
>>> }
>>>
>>> Response.Write("</tr>");
>>>
>>> //
>>> foreach (DataRow row in myTable.Rows)
>>> {
>>> if (row["au_id"].ToString() == "322-22-2222")
>>> {
>>> Response.Write("<tr>");
>>> foreach (DataColumn myColumn in myTable.Columns)
>>> {
>>> Response.Write("<td>" + row[myColumn] + "</td>");
>>> }
>>> Response.Write("</tr>");
>>> break;
>>> }
>>> }
>>> Response.Write("</table>");
>>>
>>> myConnection.Close();
>>> }
>>>
>>> }
>>>
>>>
>>>

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
most puzzle question 1 about sqlparameters.My question is following the ///.thank you. maiyude Microsoft ADO .NET 2 5th Feb 2009 01:53 AM
Kakuro Puzzle Solver Question =?Utf-8?B?QWxiaWU=?= Microsoft Excel Misc 0 20th May 2006 05:22 PM
Question: Selecting random records from the db (puzzle of the day) VB Programmer Microsoft ASP .NET 2 4th Nov 2004 12:30 PM
Search engine question: More a puzzle than a problem Regina Windows XP Internet Explorer 0 26th Jan 2004 11:20 PM
Search engine question: More a puzzle than a problem Regina Windows XP Internet Explorer 0 24th Jan 2004 05:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:20 PM.