im sending data from a web form to a web service that saves the data to a database. here is a simplified version of the web form code that creates a new row with the inputted data and passes it to the web service method InsertData.
here is a basic version of the web service code that is supposed to insert the data into a table:
first i open the connection like this:
then i try to append the data using this method :
this does not work, and i have tried many variants of this but i cant get it done. can anyone show me what im doing wrong
Code:
DataSet dataset = new System.Data.DataSet();
DataTable table = new DataTable("Feedback");
table.Columns.Add("Name");
table.Columns.Add("Phone");
table.Columns.Add("comment");
DataRow row = table.NewRow();
row["Name"] = this.TextBox1.Text;
row["Phone"] = this.TextBox2.Text;
row["comment"] = this.TextBox3.Text;
table.Rows.Add(row);
localhost.Service1 service = new Feedback.localhost.Service1();
dataset.Tables.Add("Feedback");
first i open the connection like this:
Code:
connString = "server=fintanspc; uid=fintan; pwd=nokia3210;database=Test";
conn = new SqlConnection(connString);
adapter = new SqlDataAdapter("select*from Feedback",connString);
dataSet = new DataSet();
adapter.Fill(dataSet,"Feedback");
dataTable = this.dataSet.Tables[0];
Code:
public int InsertData(DataSet data)
{
this.OpenConn();
DataRow row;
row = dataTable.NewRow();
row["Name"] = data.Tables["Feedback"].Rows[0].;
row["Phone"] = data.Tables["Phone"].Rows[0].ItemArray[1];
row["comment"] = data.Tables["comment"].Rows[0].ItemArray[2];
dataTable.Rows.Add(row);
adapter.Update(dataSet,"Feedback");
dataSet.AcceptChanges();
}