the problem i have guys is im really new to this and trying to understand it all still, i currently have a web service complete and working in vis studio 2010, the service lists films that are in an sql db, the problem i have is i need to add some function to it to be able to delete a film from the list, insert a film to the list and and update function too
i have to be honest i dont know where to start can anyone help me here? :) :)
i have enclosed a .rar file with my project in
Loading
CrishPosted Dec 13, 2010, 5:10 AM
You can refer this following code.otherwise to get more detail check this below link.
http://www.c-sharpcorner.com/UploadFile/anjudidi/108062009005713AM/1.aspx
example:
<appSettings>
<add key="connect" value="Initial Catalog=Data; Data Source=DHARMENDRA\SQLSERVER2005; uid=sa; pwd=wintellect"/>
appSettings>
The following code snippet shows how to connect to a database and create other database access related objects.
SqlDataAdapter da;
SqlConnection con;
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
This function is use to fetch data from the StudentRecord table, fills data in a DataTable object and find it to a GridView control using the DataSource property. In the end, the code calls the GridView.DataBind method to apply the binding.
public void BindData()
{
con = new SqlConnection(ConfigurationSettings.AppSettings["connect"]);
cmd.CommandText = "Select * from StudentRecord";
cmd.Connection = con;
da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Open();
cmd.ExecuteNonQuery();
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();
}
Now on the page load method, we call the FillStudentRecordGrid method.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}