Hi
I have a database with two tables
1. iSet(which contains data)
2.Table1(which is empty)

I have a program that can read from iSet.
It uses OleDB
Its working properly

The problem is that i don't know a thing about writing to a database.

The table Table1 has two fields
iAddress(of type number)
Instruction(of type string)
ID(Autonumber)

How to write values to Table1?

Thanks in advance

Try this.

static void Main(string[] args)
        {
            OleDbConnection connection = new OleDbConnection("your_connection_string_here");

            string sql = "Insert Into Table1 (iAddress, Instruction) values (@iAddress, @instruction)";
            
            OleDbParameter addressParam = new OleDbParameter("@iAddress", OleDbType.Integer);
            addressParam.Value = 1;

            OleDbParameter instructionParam = new OleDbParameter("@instruction", OleDbType.VarChar);
            instructionParam.Value = "Test";

            OleDbCommand command = new OleDbCommand(sql, connection);
            command.Parameters.Add(addressParam);
            command.Parameters.Add(instructionParam);

            connection.Open();
            command.ExecuteNonQuery();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }
commented: Thanks. It Worked +1

Wow apegram
That was fast!!!
Lemme check it out.
Thanks a lot

Thanks apegram
It worked.
Thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.