A new way of interacting and brainstorming junior programmers...
Bra how do I delete from a database? .mdb? using the SQL methods??<--Nicky-->
Sorry bra i meant OleDb;
I Hope this sintax helps You out!//Open ConnectionConnectDB();//Querystring query = "DELETE * FROM TableName WHERE FieldName = '" + ControlName + "'";Example: string query = "DELETE * FROM Account WHERE [User] = '" + txtUser.Text + "'";//OleDbDataReader MethodExecuteQuery(query);//Close ConnectionDisconnectDB();
Bra one more problem..It seems to delete.. But it will obviously have to overite all data on the actual database if something is added or deleted?? Using the UPDATE(save)..this is my code but it doesnt seem to work..ConnectDb();//Querystring qu = "UPDATE Customer SET [Name] = '" + txt_Name.Text + "', [Surname] = '";qu = qu + txt_Surname.Text + "',[TelNo] = '";qu = qu + txt_Telephone.Text + "'";qu = qu + " WHERE [ID] = '" + lbox_cID.SelectedItem.ToString() + "'";query(qu);Disconnect();it seems confusing but let me know what u think..
Try this out (without braces) and debug!string qu = "UPDATE Customer SET Name = '" + txt_Name.Text + "', Surname = '" + txt_Surname.Text + "', TelNo = '" + txt_Telephone.Text + "' WHERE ID= '" + lbox_CID.SelectedItem.ToString() + "'";ExecuteQuery(query);DisconnectDB();I hope it's useful!!!!
Here's a working example:string query = "UPDATE Account SET Pass = '" + txtPass.Text + "', [Domain] = '" + cmbDomain.SelectedItem.ToString() + "', Name = '" + txtName.Text + "', Surname = '" + txtSurname.Text + "' WHERE [User] = '" + txtUser.Text + "'"; ExecuteQuery(query); DisconnectDB();
7 comments:
Bra how do I delete from a database? .mdb? using the SQL methods??
<--Nicky-->
Sorry bra i meant OleDb;
I Hope this sintax helps You out!
//Open Connection
ConnectDB();
//Query
string query = "DELETE * FROM TableName WHERE FieldName = '" + ControlName + "'";
Example: string query = "DELETE * FROM Account WHERE [User] = '" + txtUser.Text + "'";
//OleDbDataReader Method
ExecuteQuery(query);
//Close Connection
DisconnectDB();
Bra one more problem..
It seems to delete.. But it will obviously have to overite all data on the actual database if something is added or deleted?? Using the UPDATE(save)..
this is my code but it doesnt seem to work..
ConnectDb();
//Query
string qu = "UPDATE Customer SET [Name] = '" + txt_Name.Text + "', [Surname] = '";
qu = qu + txt_Surname.Text + "',[TelNo] = '";
qu = qu + txt_Telephone.Text + "'";
qu = qu + " WHERE [ID] = '" + lbox_cID.SelectedItem.ToString() + "'";
query(qu);
Disconnect();
it seems confusing but let me know what u think..
Try this out (without braces) and debug!
string qu = "UPDATE Customer SET Name = '" + txt_Name.Text + "', Surname = '" + txt_Surname.Text + "', TelNo = '" + txt_Telephone.Text + "' WHERE ID= '" + lbox_CID.SelectedItem.ToString() + "'";
ExecuteQuery(query);
DisconnectDB();
I hope it's useful!!!!
Here's a working example:
string query = "UPDATE Account SET Pass = '" + txtPass.Text + "', [Domain] = '" + cmbDomain.SelectedItem.ToString() + "', Name = '" + txtName.Text + "', Surname = '" + txtSurname.Text + "' WHERE [User] = '" + txtUser.Text + "'";
ExecuteQuery(query);
DisconnectDB();
Here's a working example:
string query = "UPDATE Account SET Pass = '" + txtPass.Text + "', [Domain] = '" + cmbDomain.SelectedItem.ToString() + "', Name = '" + txtName.Text + "', Surname = '" + txtSurname.Text + "' WHERE [User] = '" + txtUser.Text + "'";
ExecuteQuery(query);
DisconnectDB();
Post a Comment