Najam Sikander Awan
logs of my work and digital life
logs of my work and digital life
Jan 29th
hi everyone,
today I discovered a nice tip from a blog I never knew selecting random rows were that easy with sqlserver 2000 and above. I have a country table that has four countries and from 4 I am selecting random 2.
SELECT TOP 2 * FROM country ORDER By NEWID()
select * from country
First Result
3 SaudiArabia
4 France
Second Result
1 UAE
4 France
Third Result
1 UAE
3 SaudiArabia
All Countries
1 UAE
2 Pakistan
3 SaudiArabia
4 France
Amazing right??
Jan 27th
hi guys
After playing with wordpress we decided to make a small static website using wordpress 2.7. Please check it out at http://cbhtrade.com/cbh/
Jan 27th
hi guys
well I have been learning html and css and my company let me do some slicing for them so here is my first offical html/css project please visit http://www.tdfsolutions.com .
Jan 27th
hi everyone
I am posting after a long time guess I was super busy
well first things first I have installed wordpress 2.7 on my hosting and imported all the data from my blog running at http://najam.wordpress.com.
Now a days I am busy with developing themes with wordpress and since I am stuck with windows wamp is a choice for me. One problem I run into is if I try to put custom structure for my permalinks to have more seo friendly blog it fails to show the post or page
. Anyone know whats the problem? And even if I do this for this blog you reading it would fail to show the page/post that includes the front page.
Sep 27th
hi friends
You know google chrome is out and everyone was so excited about that including me as a very passionate user i tried to do all of the things now in chrome i have imported my firefox settings (bookmarks) into chrome. All bookmarks are showing good I liked that but shortly I needed to perform a simple task in chrome that is “searching for a bookmarked site among all the bookmarks i have” and till now i don’t know how to search for my bookmark in mighty chrome.
So if anyone of you know how to seach bookmarks in chrome please let me know. And one more thing what about tags how can I tag my pages?
Jul 17th
hey guyz finally we have to learn how to update our tables in database so only for you guys here is my sample code
string giftId = GridView1.SelectedRow.Cells[0].Text.ToString(); //getting an id
SqlDataSource myDbSource = new SqlDataSource();
myDbSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
//myDbSource.InsertCommand = “update gifts set giftActivate=1 where giftId=” + Entrydate + “)”;
myDbSource.UpdateCommand = “update gifts set giftActivate=’1′ where giftId=” + giftId;
myDbSource.ProviderName = “System.Data.SqlClient”;
myDbSource.Update();
Well this code set giftActive flag to 1 for all the rows matched with giftid value.
Jul 17th
Hey guyz today i will show you how to fire delete query by using our beloved control sqldatasource.
Here is the code
SqlDataSource myDbSource22 = new SqlDataSource();
myDbSource22.ConnectionString = ConfigurationManager.ConnectionStrings["lalConnectionString"].ConnectionString;
myDbSource22.ProviderName = “System.Data.SqlClient”;
myDbSource22.DeleteCommand = “delete from ProductsGroups where pid = ” + productId;
myDbSource22.Delete();
All it does it deletes all the rows for a given productID from table productgroups. Simple right
Jul 17th
hey guyz how are you ??
Me back with my sqldatasource series. Today i will show you how to fire insert query using sqldatasource control into code behind i am using c#.
Below is the sample code UserID is the parameter passing into a function as an argument.
DateTime Entrydate = DateTime.Today;
SqlDataSource myDbSource = new SqlDataSource();
myDbSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
myDbSource.InsertCommand = “insert into tbl_invoices (user,Entrydate) values (” + UserID + “,’” + Entrydate + “‘)”;
myDbSource.ProviderName = “System.Data.SqlClient”;
myDbSource.Insert();
myDbSource.SelectCommand = “SELECT IDENT_CURRENT(‘tbl_invoices’)”;
DataView dv = (DataView)myDbSource.Select(new DataSourceSelectArguments());
DataTable dt = dv.Table;
string invNumber = dt.Rows[0][0].ToString();
return invNumber.ToString();
//return string.Empty;
Code above is very simple what it does simple take UserID as an argument and then insert a new record into tbl_invoices table and then after it i am firing a select statement that returns the latest ID into tbl_invoices table. SELECT IDENT_CURRENT(‘table name’) return the id of the last record inserted into the table.
Happy coding bye
Jul 16th
Hi in asp.net 2.0 this new datasource control has been added and i liked it alot and i used it on many places so i thought it would be nice if I share my knowledge with all my readers so first of all i would just like to show you how to retrieve some data from your database into C# code behind file.
string userID = string.Empty;
string UserName=”najam”;
SqlDataSource myDbSource = new SqlDataSource();
myDbSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
myDbSource.SelectCommand = “select userId from Users where userName=’” + UserName + “‘”;
myDbSource.ProviderName = “System.Data.SqlClient”;
DataView dv = (DataView)myDbSource.Select(new DataSourceSelectArguments());
DataTable dt = dv.Table;
if (dt.Rows.Count > 0)
{
userID = dt.Rows[0][0].ToString();
}
Above code will return user id if username supplied. You will see no data adapters or command object.
If you like instead of creating sql datasrouce control in code behind just drag and drop it onto ur aspx page and then in your code behind reference it that will shorten the line of code for fetching data from your database.
Jul 16th
Ummm whats new in my life?
Well finally my Ms in telecom is completed all courses are clear and i am fleeing like a free bird. Tension free consitration on my job no more travling in triangle from home to office and then from there to university.
Hopefully now i will get some time to write for my blog. If anyone still reading please keep reading