Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void DeleteMyObject(int objectId)
- {
- SqlConnection connectionOne = new SqlConnection("MyFirstDbConnection");
- SqlConnection connedtionTwo = new SqlConnection("MySecondDbCOnnection");
- SqlCommand myCommand = new SqlCommand(connectionOne);
- myCommand.CommandText = "DELETE FROM myTable where myid = " + objectId.ToString();
- connectionOne.Open();
- myCommand.ExecuteNonQuery();
- connectionOne.Close();
- myCommand.Connection = connectionTwo;
- connectionTwo.Open();
- myCommand.ExecuteNonQuery();
- connectionTwo.Close();
- }
- string name = (string)e.InputParameters["name"];
- int id = (int)e.InputParameters["id"];
- if (string.IsNullOrEmpty(name))
- e.Cancel = true;
- else
- {
- // Here insert in all Databases currently present
- // Except DB with StorageIndex = 1 as will b updated by ObjectDataSource1
- for (int index = 2; index <= 3; index++)
- {
- string DataConnectionString = ConfigurationManager.AppSettings["DataConnectionString " + index]);
- SqlConnection con = new SqlConnection(DataConnectionString);
- string query = "UPDATE student SET [name] = @name WHERE (([id] = @id))";
- int cnt = Utils.executeQuery(query, con, new object[] { "@name", "@id" }, new object[] { name, id });
- }
- }
- }
Add Comment
Please, Sign In to add comment