Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If i can insert values into database then i will get .net application.
how can i get this...

Thanks in advance
Posted

I suppose you require to insert values into a database via C#.
Always start with msdn - http://msdn.microsoft.com/en-us/library/ms233812%28v=vs.80%29.aspx[^].
 
Share this answer
 
This is for insert :
For retrieving You need to put some Effort try to find out by yourself



CSS
SqlConnection Con;
    SqlCommand Cmd;
    SqlDataReader dr;



C#
public string fn_insertCategoryDetails(string strCategoryName)
    {
        try
        {
            Con = new SqlConnection(ConfigurationManager.ConnectionStrings["yoConnectionString"].ConnectionString);
            Con.Open();
            Cmd = new SqlCommand("INSERT INTO InterviewCategories(Category)Values(@name)", Con);
            Cmd.Parameters.AddWithValue("@name", strCategoryName);

            if (Cmd.ExecuteNonQuery() > 0)
            {
                return "SUCCESS : Record has been inserted";
            }
            else
            {
                return "ERROR : SQL Exception";
            }
        }
        catch (Exception ex)
        {
            return "ERROR : " + ex.Message;
        }
        finally
        {
            if (Con != null)
            {
                Con.Close();
            }
        }
    }


Read This Link [^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900