help me

I programing in visual c# 2005 expres edition

and I have a problem with sending a query to database. I can receive data from

database but I can't modify data on server. When I use task: string sql =

"INSERT INTO Table(id,symbol,name) VALUES (3,tt,tttttt)";
SqlCommand aaa =

new SqlCommand(sql);
data isn't modyfied on database and compiler doesn't

return any mistakes.

[551 byte] By [niutka] at [2007-12-25]
# 1

well to modify data you need to an update command, not an insert command, the insert commands inserts new data. As well as this you need to place the single quotes ' around the string/text. Example:

"INSERT INTO Table(id,symbol,name) VALUES (3,'tt','tttttt')";

In regards to updating, the syntax should be this:

UPDATE tableName SET field1 = NewValue WHERE someField = SomeValue

so I may wish to update a table called customers, and update a field called name where the customer ID is 1:

Update customers SET name = 'bob' WHERE CustomerID = 1

if you are still having problems, tell us what database you are using (SQL/MS Access?) and where the file is placed (same directory as project output? if so you may want to take a look at this: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=427451&SiteID=1)

ahmedilyas at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 2
The thing isn't about modyfing records i db but sending queries to db,

and if you can please send some code(examples)

niutka at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 3

your original question was that you can't modify the data in SQL/database to which I gave a solution for ....

but now you are talking about sending queries to the database?

What queries would these be?

ahmedilyas at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 4
Those are simple quaries, user writes a string and then the querry runs

(looking db by this string in specific column), and the other function

of this app is inserting and modyfing the records in db

niutka at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 5

its a big topic to cover as there are many ways of doing so and many ways of retrieving data back. I would suggest running a forum search and following through examples.

I would also suggest looking at using the SqlDataReader or OleDbDataReader (if you are using MS Access) for reading values returned from a query, perhaps filling a dataset using the data adapters and reading a bit about how the INSERT/UPDATE/DELETE/SELECT commands work. There are many examples on these forums, I'm sure you will be able to learn from them :-)

ahmedilyas at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...
# 6
I have other question, i don't knew how write connection string, what parameters use. I have SQL server 2005 expres edition and my database name is MyBase.
niutka at 2007-9-3 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...