hi frnnds,
iam raghuram,
i had got a problem .when iam inserting the values in database ,it will not inserted.
i had done the coding ,but it doesn't show any mistakes.
while inserting the data it will show error on
insert.executenonquery()
so i requested pls give me the coding of inserting data into database........here iam using technologies are asp.net with vb.net,sqlserver-2005..

Hi Raghuram

Pls give exact exception and error message you are getting, then only we can help you!!

hi frnnds,
iam raghuram,
i had got a problem .when iam inserting the values in database ,it will not inserted.
i had done the coding ,but it doesn't show any mistakes.
while inserting the data it will show error on
insert.executenonquery()
so i requested pls give me the coding of inserting data into database........here iam using technologies are asp.net with vb.net,sqlserver-2005..

This is in C#, am sure you can convert it into VB.Net

string strInsert = "insert into myTable(field1, field2) values(?,?) ";
        openConnection();
        OleDbCommand myCommand = new OleDbCommand(strUpdate, cnConnection);

        myCommand.CommandType = CommandType.Text;

        myCommand.Parameters.Add(new OleDbParameter("@field1", OleDbType.VarChar));
        myCommand.Parameters["@field1"].Direction = ParameterDirection.Input;
        myCommand.Parameters["@field1"].Size = 150;
        myCommand.Parameters["@field1"].Value = "value 1";

myCommand.Parameters.Add(new OleDbParameter("@field2", OleDbType.VarChar));
        myCommand.Parameters["@field2"].Direction = ParameterDirection.Input;
        myCommand.Parameters["@field2"].Size = 150;
        myCommand.Parameters["@field2"].Value = "value 2";

try
        {
            intAdd = myCommand.ExecuteNonQuery();
        }
        catch (OleDbException ex)
        {
           //display error
        }
        finally
        {
            myCommand.Dispose();
            closeConnection();
        }
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.