Friday, March 30, 2012

Updating Data Sources with DataAdapters (ADO.NET)

private void AdapterUpdate(string connectionString)
{
using (SqlConnection connection = new SqlConnection(connectionString))

{
SqlDataAdapter dataAdpater = new SqlDataAdapter("SELECT [Emp_ID], [User_Name], [Level], [Email_ID], [User_Full_Name], [Is_Active] FROM [LOGIN]",connection);

dataAdpater.UpdateCommand = new SqlCommand("UPDATE [LOGIN] SET [User_Name] = @User_Name " + "WHERE Emp_ID = @Emp_ID", connection);

dataAdpater.UpdateCommand.Parameters.Add("@User_Name", SqlDbType.NVarChar, 15,"User_Name");

SqlParameter parameter = dataAdpater.UpdateCommand.Parameters.Add("@Emp_ID", SqlDbType.Int);
parameter.SourceColumn = "Emp_ID";
parameter.SourceVersion = DataRowVersion.Original;

DataTable categoryTable = new DataTable();
dataAdpater.Fill(categoryTable);

DataRow categoryRow = categoryTable.Rows[0];
categoryRow["User_Name"] = "sivaji the boss";

dataAdpater.Update(categoryTable);



Console.WriteLine("Rows after update.");
foreach (DataRow row in categoryTable.Rows)
{
{
Console.WriteLine("{0}: {1}", row[0], row[1]);
}
}
}
}

Thursday, March 8, 2012

how to create new window in response.write fn in c#

Response.Write("<script language=javascript>window.open('./image/"+btn.CommandArgument+"','win','toolbar=0,location=0,directories=0,status=1, menubar=1,scrollbars=1,resizable=1,"+"width=600,height=600');</script>");


we can useany url in the part of(./image/"+btn.CommandArgument+")