Monday, February 27, 2012

help me, i am using MS-VWD2005

Hi, If some one can help me, i am using MS-VWD2005, i want to connect with the DB by using "Conncetionstring" and "Open" and "do while EOF" and not to use the tools & controls in the VWD.. Thanks

Is this what are you trying to achieve:

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand command = connection.CreateCommand();
command.CommandText = "SELECT * FROM TestTable";
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
// do whatever you want...
}
connection.Close();

|||
string cnStr ="" ;//your connection stringstring qry ="Select paymentdate from tblPayments"; SqlConnection con =new SqlConnection(cnStr); con.Open(); DataSet ds =new DataSet(); SqlDataAdapter da =new SqlDataAdapter(qry, con); da.Fill(ds);// Loop through the rows of the only table in the DataSetforeach( DataRow dataRowin ds.Tables[0].Rows) {//say do something as below Response.Write(dataRow["paymentdate"].ToString()); }

No comments:

Post a Comment