M
mo
Hi,
I am trying to insert/update to a sql server and It does not either
insert or updates but the code does not fail (it is doing something)
any ideas?
try
{
string connString = "Data Source=server1;Initial Catalog=Test;User
ID=sa;Password=;";
SqlConnection myConnection = new SqlConnection(connString);
SqlDataAdapter mysqlDataAdapter = new SqlDataAdapter("SELECT *
from Links",myConnection);
myConnection.Open();
DataSet myDataSet = new DataSet();
DataRow mydataRow;
SqlCommandBuilder mySqlCommandBuilder =new
SqlCommandBuilder(mysqlDataAdapter);
mysqlDataAdapter.MissingSchemaAction=MissingSchemaAction.AddWithKey;
mysqlDataAdapter.Fill(myDataSet,"Links");
myDataSet.Tables["Links"].Rows[0]["Name"] = "peach";
mydataRow = myDataSet.Tables["Links"].NewRow();
mydataRow["Name"] = "xxxx";
label2.Text = "inserted in the table";
myDataSet.Tables["Links"].Rows.Add(mydataRow);
myConnection.Close();
}
catch
{
label2.Text = "database insert failed ";
}
I am trying to insert/update to a sql server and It does not either
insert or updates but the code does not fail (it is doing something)
any ideas?
try
{
string connString = "Data Source=server1;Initial Catalog=Test;User
ID=sa;Password=;";
SqlConnection myConnection = new SqlConnection(connString);
SqlDataAdapter mysqlDataAdapter = new SqlDataAdapter("SELECT *
from Links",myConnection);
myConnection.Open();
DataSet myDataSet = new DataSet();
DataRow mydataRow;
SqlCommandBuilder mySqlCommandBuilder =new
SqlCommandBuilder(mysqlDataAdapter);
mysqlDataAdapter.MissingSchemaAction=MissingSchemaAction.AddWithKey;
mysqlDataAdapter.Fill(myDataSet,"Links");
myDataSet.Tables["Links"].Rows[0]["Name"] = "peach";
mydataRow = myDataSet.Tables["Links"].NewRow();
mydataRow["Name"] = "xxxx";
label2.Text = "inserted in the table";
myDataSet.Tables["Links"].Rows.Add(mydataRow);
myConnection.Close();
}
catch
{
label2.Text = "database insert failed ";
}