hello

Sunday, 25 November 2012

how pass sp perametrs in sqlhelper

           SqlHelper.ExecuteNonQuery(con, CommandType.StoredProcedure, "spname", new SqlParameter("@username", txtuname.Text.ToString().Trim()));

Friday, 23 November 2012

change gridview checkbox color using javascript

 <script type="text/javascript">
        function changecolor(Id) {
            if (document.getElementById(Id).checked == true) {
                document.getElementById(Id).parentNode.style.backgroundColor = 'green';
            }
            else {
                document.getElementById(Id).parentNode.style.backgroundColor = 'red';
            }


        }
    </script>
</head>

onclick="javascript:changecolor(this.id)"

how get database table and no of rows in table

SELECT Name, DCount("*", Name) AS NumberOfRows
FROM MSysObjects
WHERE TYPE IN (1, 4, 6)
AND Name NOT LIKE "MSys*"
ORDER BY Name

Friday, 16 November 2012

how get max id in sql

            SELECT ISNULL(MAX(ISNULL(id, 0)), 0) + 1 FROM temp2

exeption handling in sql

 BEGIN TRANSACTION
        BEGIN TRY
            -- Generate a Constraint violation Error.
            DELETE FROM IRCContactDetails
                    WHERE id = 6
        END TRY
        BEGIN CATCH
            SELECT
                    ERROR_NUMBER() AS ErrorNumber,
                    ERROR_SEVERITY() AS ErrorSeverity,
                    ERROR_STATE() AS ErrorState,
                    ERROR_MESSAGE() AS ErrorMessage

            IF @@TRANCOUNT > 0
                    ROLLBACK TRANSACTION;                   
        END CATCH;
       
        IF @@TRANCOUNT > 0
            COMMIT TRANSACTION;

Wednesday, 31 October 2012

how conver number into words

public string retWord(int number)
    {

        if (number == 0) return "Zero";
        if (number == -2147483648) return "inus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight";
        int[] num = new int[4];
        int first = 0;
        int u, h, t;
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        if (number < 0)
        {
            sb.Append("Minus");
            number = -number;
        }
        string[] words0 = { "", "One ", "Two ", "Three", "Four ", "Five", "Six ", "Seven", "Eight ", "Nine " };
        string[] words = { "Ten", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " };
        string[] words2 = { "Twenty ", "Thirty", "Forty", "Fifty ", "Sixty ", "Seventy", "Eighty", "Ninety" };
        string[] words3 = { "Thousand ", "Lakh", "Crore" };
        num[0] = number % 1000; // units
        num[1] = number / 1000;
        num[2] = number / 100000;
        num[1] = num[1] - 100 * num[2]; // thousands
        num[3] = number / 10000000; // crores
        num[2] = num[2] - 100 * num[3]; // lakhs
        for (int i = 3; i > 0; i--)
        {
            if (num[i] != 0)
            { first = i; break; }
        }

        for (int i = first; i >= 0; i--)
        {
            if (num[i] == 0) continue;
            u = num[i] % 10; // ones
            t = num[i] / 10;
            h = num[i] / 100; // hundreds
            t = t - 10 * h; // tens
            if (h > 0) sb.Append(words0[h] + "Hundred ");
            if (u > 0 || t > 0)
            {
                if (h > 0 || i == 0) sb.Append("and ");
                if (t == 0)
                    sb.Append(words0[u]);
                else if (t == 1)
                    sb.Append(words[u]);
                else
                    sb.Append(words2[t - 2] + words0[u]);
            }
            if (i != 0) sb.Append(words3[i - 1]);
        }
        return sb.ToString().TrimEnd();

    }

how genrate 8 disit rendom number

    public string Get8Digits()
    {
        var bytes = new byte[4];
        var rng = RandomNumberGenerator.Create();
        rng.GetBytes(bytes);
        uint random = BitConverter.ToUInt32(bytes, 0) % 100000000;
        return String.Format("{0:D8}", random);
    }

Friday, 26 October 2012

DELETE TRIGGER


CREATE TRIGGER [dbo].[Student_Update]
ON [dbo].StudMarks
AFTER DELETE
AS
BEGIN
INSERT INTO StudMarks2 SELECT Regdno,MathsMarks,StatsMarks,CompScienceMarks,TotMarks,AvgMarks FROM DELETED
END
 

Wednesday, 24 October 2012

java script funcation for open panel

<script type="text/javascript">
        function ff() {
            document.getElementById("a").style.display = "block";
        }
        function ff2() {
            document.getElementById("a").style.display = "none";
        }
    </script>

 <div class="GridviewDiv" id="a" style="display: none">
contanet div that will be open
</div>

call
    <asp:DropDownList ID="DropDownList1" runat="server" onmouseover="javascript:ff()" >
    </asp:DropDownList>

auto referesh grid and update panel

.aspx;
<asp:ScriptManager ID="ScriptManager1" runat="server" />
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:Timer ID="AutoRefreshTimer" runat="server" Interval="5000" OnTick="AutoRefreshTimer_Tick" />
                            <asp:GridView ID="gvrecords" runat="server" AutoGenerateColumns="False" AllowSorting="true"
                                Width="540px" CssClass="Gridview">
                                <Columns>
                                    <asp:TemplateField HeaderText="UserName">
                                        <ItemTemplate>
                                            <asp:Label ID="lblFirstname" Text='<%# Eval("name") %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </ContentTemplate>
                    </asp:UpdatePanel>


.cs

  protected void AutoRefreshTimer_Tick(object sender, EventArgs e)
    {
        BindUserDetails();(fill grid funcation)
      
    }

Tuesday, 23 October 2012

Fill Dataset Using Reader


SqlDataReader dr;
            SqlConnection connection = new SqlConnection(sqlConnectString);
            SqlCommand command = new SqlCommand(sqlSelect, connection);
            connection.Open( );
            dr = command.ExecuteReader( );

            // Create the DataSet using the DataSet.Load( ) method
            DataSet ds = new DataSet( );
            ds.Load(dr, LoadOption.OverwriteChanges,
                new string[ {"Department", "Contact"});

            int tableCount = 0;
            foreach(DataTable dt in ds.Tables)
            {
                Console.WriteLine("Table {0}; Name = {1}", tableCount++,
                    dt.TableName);
                foreach(DataRow row in dt.Rows)
                {
                    for(int i = 0; i < dt.Columns.Count; i++)
                        Console.Write("{0} = {1};", dt.ColumnsIdea.ColumnName,
                            rowIdea);
                    Console.WriteLine( );
                }
                Console.WriteLine( );
            }

            Console.WriteLine("Press any key to continue.");
            Console.ReadKey( );

Fill Datatable Using DataReader

private DataTable GetDataTable()
{
  string sql = "SELECT Id, Description FROM MyTable";
  using (SqlConnection myConnection = new SqlConnection(connectionString))
  {
    using (SqlCommand myCommand = new SqlCommand(sql, myConnection))
    {
      myConnection.Open();
      using (SqlDataReader myReader = myCommand.ExecuteReader())
      {
        DataTable myTable = new DataTable();
        myTable.Load(myReader);
        myConnection.Close();
        return myTable;
      }
    }
  }
}

Monday, 22 October 2012

How Call sqlhelper sp in c#


DataGrid1.DataSource = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "getEmployeeDetailsByEmployeeId", new SqlParameter("@EmployeeID", 1));
DataGrid1.DataBind();

or

    



Forums » .NET » ASP.NET »

   
How to call stored procedure

Posted Date: 04 Apr 2012      Posted By:: varalakshmi     Member Level: Bronze    Member Rank: 4670     Points: 1   Responses: 4



Hi to All,

how to call stored procedure in code behind using sqlhelper.i would need to help.



Thanks & Regards
Varalakshmi.P


       


inShare
Responses
#665012    Author: Rajalingam      Member Level: Silver      Member Rank: 593     Date: 04/Apr/2012   Rating: 2 out of 52 out of 5     Points: 4

Hi,


Us this below code

string _connectionString=mention your database server details

SqlConnection conn = new SqlConnection(_connectionString)
SqlCommand cmd = new SqlCommand("select_directory_groups", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@directory_id", directoryID);

SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();


da.Fill(ds);
retutn ds


#665015    Author: Bijit      Member Level: Gold      Member Rank: 146     Date: 04/Apr/2012   Rating: 2 out of 52 out of 5     Points: 4

try this code........
public static string GetConnStr()
{
string conn = "put connection string here";
return conn;

}

/// <summary>
/// Returns filled dataset from stored procedure name and its parameters
/// </summary>
public DataSet FillDataset(string sProc, SqlParameter[] parameter, object[] values)
{
return FillDataset(sProc, parameter, values, DataAccess.GetConnStr());
}

/// <summary>
/// Returns filled dataset from stored procedure name and its parameters
/// </summary>
public static DataSet FillDataset(string sProc, SqlParameter[] parameter, object[] values, string ConStr)
{
using (SqlConnection myConnection = new SqlConnection(ConStr))
{
using (SqlDataAdapter myAdapter = new SqlDataAdapter())
{

myAdapter.SelectCommand = new SqlCommand(sProc, myConnection);
myAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;

// assign all parameters with its values
for (int i = 0; i < parameter.Length; i++)
{
myAdapter.SelectCommand.Parameters.Add(parameter[i]).Value = values[i];
}

DataSet myDataSet = new DataSet();

myAdapter.Fill(myDataSet);

return myDataSet;
}
}
}


#665029    Author: Anil Kumar Pandey      Member Level: Platinum      Member Rank: 1     Date: 04/Apr/2012   Rating: 2 out of 52 out of 5     Points: 3

Please check this below sample code.


SqlParameter spc = new SqlParameter[4];
spc = SqlHelperParameterCache.GetSpParameterSet(cnn,"SPNAME");

spc[0]=productID
spc[1]=productName
spc[2]=unitPrice
spc[3]=qtyPerUnit

SqlHelper.ExecuteNonQuery(cnn, CommandType.StoredProcedure,"SPNAME",spc);

//

WebService Example

 [WebMethod]
    public DataSet GetUserDetails()
    {
        SqlConnection con = new SqlConnection("Data Source=COM-827A9D94467;Initial Catalog=test;Integrated Security=True");
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from TabLogindetails", con);
        cmd.ExecuteNonQuery();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        // Create an instance of DataSet.
        DataSet ds = new DataSet();
        da.Fill(ds);
        con.Close();
        // Return the DataSet as an XmlElement.
        return ds;
    }

//aspx
localhost.WebService objUserDetails = new localhost.WebService();
            dsresult = new DataSet();
            dsresult = objUserDetails.GetUserDetails();
            gvUserDetails.DataSource = dsresult;
            gvUserDetails.DataBind();

How Call StoredProcedure in c# Directly

Query = "exec spname '" + txtUserName.Text + "', '" + txtPassword.Text + "','" + ddlinsti.SelectedValue + "'";

How Call StoredProcedure in c#


        con = new SqlConnection("Data Source=122;Initial Catalog=test;Integrated Security=True");
        con.Open();
        cmd = new SqlCommand("GetLoginDetail", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@name", SqlDbType.VarChar).Value = txtUserName.Text;
        cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = txtPassword.Text;
        cmd.Parameters.Add("@inst_id", SqlDbType.VarChar).Value = ddlinsti.SelectedValue;

        SqlDataAdapter da = new SqlDataAdapter();
        da.SelectCommand = cmd;
        DataSet ds = new DataSet();
        da.Fill(ds);
        con.Close();

Parameteris Query in c#

SqlCommand comm = new SqlCommand("INSERT INTO desg VALUES (@txtsno, @txtdesg, @txtbasic)", connection);

your_db.Open();
try {
    comm.Parameters.AddWithValue("@txtsno", txtsno.Text.Trim());
    comm.Parameters.AddWithValue("@txtdesg", txtdesg.Text.Trim());
    comm.Parameters.AddWithValue("@txtbasic", txtbasic.Text.Trim());
    comm.ExecuteNonQuery();
    comm.Dispose();
    comm = null;
}
catch(Exception ex)
{
    throw new Exception(ex.ToString(), ex);
}
finally
{
    your_db.Close();
}

Thursday, 18 October 2012

how send more than one query string

Response.Redirect("Default2.aspx?UserId="+txtUserId.Text+"&UserName="+txtUserName.Text);

Monday, 27 August 2012

row number and rank in sql server

select top 100 RANK() over(order by cust_po_no) as pono, * from dbo.tbl_cust_po_mst



select top 100 Row_number() over(order by cust_po_no) as pono, * from dbo.tbl_cust_po_mst

Thursday, 23 August 2012

MODULEL WISE REPORT STORE PROCEDURE

create proc [dbo].[Issue_Log_App_Pie]
as
begin
declare
@NonSAP numeric(8,2)declare @SAP numeric(8,2)declare @LMDM numeric(8,2)declare @Total numeric(8,2)create table #AppPie(App Varchar(50),Ticket Numeric(8,2))set @NonSAP =(SELECT count(*) as TOTAL_ISSUE from showissuelog where Application_Type_Id=2GROUP BY APPLICATION_TYPE) set @SAP=(SELECT count(*) as TOTAL_ISSUE from showissuelog where Application_Type_Id=1 and Application_id not in (3)GROUP BY APPLICATION_TYPE)set @LMDM=(SELECT count(*) as TOTAL_ISSUE from showissuelog where Application_Type_Id=1 and Application_id in (3)GROUP BY APPLICATION_TYPE)set @Total=(@NonSAP+@SAP+@LMDM)set @NonSAP=(@NonSAP/@Total)*100set @SAP=(@SAP/@Total)*100set @LMDM=(@LMDM/@Total)*100insert into #AppPie values ('Non SAP',@NonSAP)insert into #AppPie values ('SAP',@SAP)insert into #AppPie values ('LMDM',@LMDM)select * from #AppPieend

Monday, 13 August 2012

working with data grid in asp.net c#

<asp:DataGrid ID="DgList" runat="server" AutoGenerateColumns="false" OnItemCommand="DgList_ItemCommand"
OnSelectedIndexChanged="DgList_SelectedIndexChanged"><Columns><asp:BoundColumn DataField="Emp_id" Visible="false"></asp:BoundColumn><asp:BoundColumn DataField="Emp_Name" HeaderText="Emp Name"></asp:BoundColumn><asp:BoundColumn DataField="Dept_Desc" HeaderText="Dept Name"></asp:BoundColumn><asp:BoundColumn DataField="Salary" HeaderText="Salary"></asp:BoundColumn><asp:ButtonColumn CommandName="edit" HeaderText="Edit" Text="Edit"></asp:ButtonColumn><asp:ButtonColumn CommandName="del" HeaderText="Delete" Text="Delete"></asp:ButtonColumn></Columns></asp:DataGrid>
.cs
protected void DgList_SelectedIndexChanged(object sender, EventArgs e){
}

protected void DgList_ItemCommand(object source, DataGridCommandEventArgs e){

string id = e.Item.Cells[0].Text;
if (e.CommandName == "edit"){
Response.Redirect(
"EditEmp.aspx?q=" + id);}

if (e.CommandName == "del"){
Delete(id);
}
}

Wednesday, 25 July 2012

gridview datakey value in asp.net

LinkButton lbtn = sender
GridViewRow gvrow = (GridViewRow)lbtn.NamingContainer;
as LinkButton;string ss = GridView1.DataKeys[gvrow.RowIndex].Value.ToString();

Tuesday, 24 July 2012

clear sesson after logout

//if sesson not null

Response.ClearHeaders();
Response.AddHeader(
Response.AddHeader(
"Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");"Pragma", "no-cache");

//logeout

sesson.clear();
sesson.abendon();

Thursday, 19 July 2012

cookies in asp.net c#

int flag = 0;
       
           SqlCommand com = new SqlCommand("select * from login", con);    
      
            SqlDataReader dtr;
            dtr = com.ExecuteReader();
            while (dtr.Read())
            {
                              
                if(dtr[0].ToString().Equals(TextBox1.Text) && dtr[1].ToString().Equals(TextBox2.Text))
                {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1)
            {
                HttpCookie uname = new HttpCookie("username");
              
                HttpCookie rights = new HttpCookie("rights");               
                uname.Value = TextBox1.Text;
           
                rights.Value = dtr[2].ToString();
                Response.Cookies.Add(uname);
        
                Response.Cookies.Add(rights);
                Response.Redirect("default.aspx");                    
            }

Wednesday, 18 July 2012

gridview edit in asp.net c#

<asp:TemplateField HeaderText="DETAIL/UPDATE" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"><ItemTemplate><asp:LinkButton ID="LinkButton2" runat="server" ForeColor="Black" OnClick="LinkButton2_Click">SHOW</asp:LinkButton></ItemTemplate>


protected void LinkButton2_Click(object sender, EventArgs e)
    {
                    LinkButton lbtn = sender as LinkButton;
            GridViewRow gvrow = (GridViewRow)lbtn.NamingContainer;
            string ss = GridView1.DataKeys[gvrow.RowIndex].Value.ToString();
}
</asp:TemplateField>

gridview edit in vb

<asp:TemplateField HeaderText="/UPDATE" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"><ItemTemplate><asp:LinkButton ID="LinkButton2" runat="server" ForeColor="Black" OnClick="LinkButton2_Click">SHOW</asp:LinkButton></ItemTemplate>


 Protected  Sub LinkButton2_Click(ByVal sender As Object, ByVal e As EventArgs)
                    Dim lbtn As LinkButton =  sender as LinkButton

            Dim gvrow As GridViewRow = CType(lbtn.NamingContainer, GridViewRow)

            Dim ss As String =  GridView1.DataKeys(gvrow.RowIndex).Value.ToString()

End Sub
<asp:LinkButton ID="LinkButton2" runat="server" ForeColor="Black"
<ItemTemplate>
</asp:TemplateField>
asp:TemplateField HeaderText="UPDATE" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left">

Tuesday, 17 July 2012

Start .vb page in vb.net

Imports System

Imports System.Collections

Imports System.Configuration

Imports System.Data

Imports System.Linq

Imports System.Xml.Linq

Imports
 Partial
Inherits System.Web.UI.Page
 Dim c1 As clsConnection = New clsConnection()Dim ds As DataSet = New DataSet()Dim tr As SqlTransactionDim con As SqlConnection = New SqlConnection("Data Source=EV001F294E678D\SQLEXPRESS;Initial Catalog=oee;Integrated Security=True")


Public Class Default4
System.Data.SqlClient

CLASS for fillRadioButtonList in vb.net

CLASS   for  fillRadioButtonList
 Dim con As SqlConnection = New SqlConnection()
    Dim com As SqlCommand = New SqlCommand()
    Dim da As SqlDataAdapter = New SqlDataAdapter()
    Dim constr As String = "Data Source=SERVER NAME \SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=True"
               
  Public Sub fillRadioButtonList(ByVal query As String, ByVal objDDL As RadioButtonList, ByVal colfield As String, ByVal valField As String)

        If con.State = ConnectionState.Closed Then
            con.ConnectionString = constr
            con.Open()
        End If
        Dim ds As DataSet = New DataSet()
        objDDL.Items.Clear()
        da = New SqlDataAdapter(query, con)
        da.Fill(ds)

        objDDL.DataSource = ds.Tables(0)
        objDDL.DataTextField = colfield
        objDDL.DataValueField = valField
        objDDL.DataBind()
    End Sub

CLASS for ExecuteNonQuery in vb.net

CLASS   for  ExecuteNonQuery
 Dim con As SqlConnection = New SqlConnection()
    Dim com As SqlCommand = New SqlCommand()
    Dim da As SqlDataAdapter = New SqlDataAdapter()
    Dim constr As String = "Data Source=SERVER NAME \SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=True"
               
 Public Sub ExecuteQuery(ByVal str As String)
        If con.State = ConnectionState.Closed Then
            con.ConnectionString = constr
            con.Open()
        End If
        com.CommandText = str
        com.Connection = con
        da.SelectCommand = com
        com.ExecuteNonQuery()
        con.Close()
    End Sub

updat In VB.NET

      Dim s As String = "UPDATE  [avail_main]  set [ideal_time_pass]='" & idealtime & "'"

          Dim com4 As SqlCommand = New SqlCommand(s, con)
       
        com4.ExecuteNonQuery()

if statement and calculation In VB.NET

            Dim l1 As Label = row.FindControl("lblfactor")        
  
            If  l1.Text = "STD. CYCLE TIME" Then

                totstandcycletiem = (totstandcycletiem + (Convert.ToDecimal(t1)))

            End If

            If  l1.Text = "SYSTEM DOWN TIME" Then

                totsystemdowntime1 = (totsystemdowntime1 + (Convert.ToDecimal(t1)))

            End If

            If  l1.Text = "PERFORMANCE DOWN TIME" Then

                totperformancedt1 = (totperformancedt1 + (Convert.ToDecimal(t1)))

            End If

ExecuteNonQuery In VB.NET

con.Open()              
                Dim savemain As String = "INSERT INTO avail_main([equip_id])VALUES('" & ddlEquipment.SelectedValue & "')"
                Dim com As SqlCommand = New SqlCommand(savemain, con)              
                com.ExecuteNonQuery()
con.close()

FOR EACH LOOP IN VB.NET

  Protected Sub SecondGridBind()
        Dim row As GridViewRow
        For Each row In GridView1.Rows
            Dim lblid As HiddenField = row.FindControl("Label2")
            Dim str As String = "select * from  fact_dtl_mst where fact_id='" & lblid.Value & "'"           
        Next
    End Sub

ExecuteScalar IB VB.NET

CLASS  
 Dim con As SqlConnection = New SqlConnection()
    Dim com As SqlCommand = New SqlCommand()
    Dim da As SqlDataAdapter = New SqlDataAdapter()
    Dim constr As String = "Data Source=SERVER NAME \SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=True"

  Public Function SelectScalar(ByVal str As String) As String
        Dim s1 As String
        If con.State = ConnectionState.Closed Then
            con.ConnectionString = constr
            con.Open()
        End If
        com.CommandText = str
        com.Connection = con
        da.SelectCommand = com
        s1 = Convert.ToString(com.ExecuteScalar())
        con.Close()
        Return s1
    End Function
  Dim c1 As clsConnection = New clsConnection()//OBJECT OF CLASS
PAGE
Dim check As String = "select count(equip_id) from TBLNAEM where equip_id='" & ddlEquipment.SelectedValue & "' "
        Dim i As Integer = (Convert.ToInt32(c1.SelectScalar(check)))

FILL DROPDOWNLIST IN VB.NET


CLASS...
    Dim con As SqlConnection = New SqlConnection()
    Dim com As SqlCommand = New SqlCommand()
    Dim da As SqlDataAdapter = New SqlDataAdapter()
    Dim constr As String = "Data Source=SERVERNAEM\SQLEXPRESS;Initial Catalog=DBNAME;Integrated Security=True"
Public Sub FillDropdownListwithvalue(ByVal query As String, ByVal objDDL As DropDownList, ByVal colfield As String, ByVal valField As String)
        If con.State = ConnectionState.Closed Then
            con.ConnectionString = constr
            con.Open()
        End If
        Dim ds As DataSet = New DataSet()
        objDDL.Items.Clear()
        da = New SqlDataAdapter(query, con)
        da.Fill(ds)
        Dim Newtbl As DataTable = New DataTable()
        Dim NewRow As DataRow = ds.Tables(0).NewRow()
        NewRow(colfield) = "-Please Select-"
        Newtbl = ds.Tables(0)
        Newtbl.Rows.InsertAt(NewRow, 0)
        Newtbl.AcceptChanges()
        Newtbl = Newtbl.Copy()
        objDDL.DataSource = ds.Tables(0)
        objDDL.DataTextField = colfield
        objDDL.DataValueField = valField
        objDDL.DataBind()
    End Sub
PAGE....
    Dim c1 As clsConnection = New clsConnection()
   Public Sub filldropdown()
        Dim s As String = "select * from TBLNAME" 
        c1.FillDropdownListwithvalue(s, ddlEquipment, "equip_desc", "equip_id")
  
    End Sub