Sunday, August 16, 2009

Best VB.NET 2005/2008 Books

Hi,
If you want to become vb.net expert buy these books depending on what version of
.Net Plateform you are using.
You can buy them on bn.com.




SQL Server 2005 Authentication

How a add SQL Login to SQL Server

FIRST STEP

1-Login to SSMS with Windows Authentication

2-Click on Security/Login

3-RC Login/Add New Login

4-Enter name/Choose SQL Authentication/Enter strong password(8 characters min with
special key @#...) and click OK.






SECOND STEP: Assign grants

1-Login in again with Windows Auth

2-Click on Databases then choose the db on which you want to assign User

3-Go to security(inside the db) then Users

4-RC Users/Add New User

5-Click on Eclipse after Login name and select login will popup

6-Enter first 2 letters of the user you want to add and click on Check Name Button

7-Choose the name of the user you added on first step and click OK twice.

8-Copy the same name on step 7 and paste on the textbox after Username

9-Under Schemas owned by this user choose appropriate schemas especially db_datareader,
db_datawriter,db_datacessadmin,db_owner).You can add more later.

10-Database role membership choose roles for this user(Usually the same as 9) and click OK.





You done with SQL Authentication.
Start SSMS and login with the user and password you just created. Make sure you choose SQL Server Authentication.

Thursday, August 13, 2009

Solution to this error:Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)

Just turn off recursives triggers,views ,functions and store pro wich
cause the problem.
For trigger for example Go to SSMS,open the table in question,open trigger folder
and right click the trigger that cause the problem and choose disable.
You should be good to go.


Talley Ouro
Developer

Saturday, August 8, 2009

Useful JavaScripts for DataGrid control






This codes will help you with your datagrid activities.
You have to add a CheckBox to datagrid.

HTML Code


this html tag adds a checkbox to header 1-add asp:TemplateColumn tag
2-add HeaderTemplate tab
3-add input tag with id=checkAll,type=checbox,onclick=DGSelectOrUnselectAll('DataGrid1',this,'chkDel')

this html tag adds checkbox to datagrid 1-add ItemTemplate tag
2-add asp checkbox control within ItemTemplate tag with id=chkDel,RunAt=server


JavaScript codes:Add these js code in
section of HTML

this is to select or unselect the datagrid check boxes

function DGSelectOrUnselectAll(grdid,obj,objlist){
//this function decides whether to check or uncheck all
if(obj.checked)
DGSelectAll(grdid,objlist)
else
DGUnselectAll(grdid,objlist)
}
//----------

function DGSelectAll(grdid,objid){
//.this function is to check all the items
var chkbox;
var i=2;

chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);

while(chkbox!=null){
chkbox.checked=true;
i=i+1;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
}

}//--------------

function DGUnselectAll(grdid,objid){
//.this function is to uncheckcheck all the items
var chkbox;
var i=2;

chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);

while(chkbox!=null){
chkbox.checked=false;
i=i+1;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
}
}

If you have question please email me at johnstalley@live.com
My name is Talley Ouro,Developer in Raleigh,NC

Thursday, August 6, 2009

How to hack "Failed to query a list of database names from the SQL Server"

Sometimes ASP.NET Configuration Tool(ASP.NET) is a pain in the ass when trying to add aspnet.db for role management.

By default on Vista the current user on the machine is not a member of SysAdmin on SQL Server 2005/2008.

So here is the trick.

1-Open Sql Server Surface Area Configuration tool from C:\Program Files\Microsoft SQL Server 2005/2008.






2-When the screen pops up click on Add New Administrator.





-on top right make sure that User to provision=Username of the pc
-on your left (Available Privileges) select Member of SQL Server SysAdmin and click on the right arrow (>)
-click ok and you should be ready to go.

My name is Talley Ouro,Developer in Raleigh,NC
Blog: http://talleyblogs.blogspot.com/
Email:johnstalley@live.com

Sunday, August 2, 2009

Code to add JavaScript confirmation dialog to a button in a datagrid




Here is the code.It is free like "free beer".If you have question send me email at johnstalley@live.com.Remember datagrid index it 0 based.
NB You could add another parameter to the function that will execute when click=ok



public static void AddConfirm(DataGrid theGrid, int columnNumber, string question)
{
//for each row in the DataGrid
foreach(DataGridItem item in theGrid.Items)
{
//for each webcontrol in the column
foreach(WebControl control in item.Cells[columnNumber].Controls)
//if it is a LinkButton or Button
{
if(control is LinkButton || control is Button)
//add the attribute
control.Attributes.Add("OnClick", " javascript:return confirm('" + question + "');");
}
}
}

How to color a row of DataGrid in ASP.NET 2.0/3.5



1-Here is the code in VB.NET 2005/2008
The name i gave empGrid to the datagrid.To do this go the property of datagrid and
click on the events section and double click on ItemDataBound event and add the code.

Protected Sub empGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles empGrid.ItemDataBound

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then

Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim Status As String = Convert.ToString(drv.Row.Item("Status"))

If Status = "Active" Then
e.Item.Cells(4).BackColor = Drawing.Color.Green

ElseIf Status = "Inactive" Then
e.Item.Cells(4).BackColor = Drawing.Color.Red

End If
End If
End Sub
1-Here is the code in C# 2005/2008
The name i gave empGrid to the datagrid.To do this go the property of datagrid and
click on the events section and double click on ItemDataBound event and add the code.

private void empGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView Drv = (DataRowView)e.Item.DataItem;
// Get fourth column value.The coloumn needed
String Status = Convert.ToString(rv.Row.ItemArray[4]);
if (Status =="Active")
{
e.Item.Cells[4].BackColor = Color.Green;
}
//Just add the remaining steps
}
}

This code is free like "Free Coffee"

Talley Ouro

About Me

My photo
Raleigh, NC, United States
I am a software developer based in Raleigh,NC,USA.I design softwares and systems ;i also do consulting for companies worldwide.I program with these languages:VB.NET 2003/2005/2008;C#;Java(fun),SQL(200,2005,2008);ASP.NET 2.0/3.5;ASP.NET AJAX;ASP.NET MVC;JavaScript;JQuery;Windows Workflow Foundation;Web Services.I have 4 years + in programming.