Very basic stupid question

  • Thread starter Thread starter mo
  • Start date Start date
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 ";
}
 
Hi mo,

You don't have an update call. In VB .Net it works like this:
Try

da.Update(ds, "d")

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

HTH,

Bernie Yaeger
 
Back
Top