Re: what am I doing wrong ?

Tech-Archive recommends: Fix windows errors by optimizing your registry



Slimshin,

Your code is not complete to update, you can add this,
OleDbConnection con;
try
{
OleDbDataAdapter dbad;
DataSet ds;
DataRow dr;
con = new
OleDbConnection(testacc.Properties.Settings.Default.mytestConnectionString);
dbad = new OleDbDataAdapter("select * from who",con);
ds = new DataSet();
dbad.Fill(ds, "who");
dr=ds.Tables["who"].NewRow();
dr["name"] = "Joe";
dr["adress"] = "123 anystreet";
dr["age"] = 25;
ds.Tables["who"].Rows.Add(dr);
SQLCommandBuilder cmd = new SQLCommandBuilder();
cm = cmd(OleDBbDataAdapter);
OleDbDataAdapter.Fill(ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finnaly
{
con.close;
}

Now you can see what goes wrong if that still happen (I have typed this
direct in this message and did a long time not use the commandbuilder).

As it is working you can refactor your code, by instance using "using" for
the connection does make it look nicer.

I hope this helps,

Cor





con.Close();


.



Relevant Pages

  • Re: Memory Leak in swing application (ImageIcon problem)
    ... private class Person extends Object { ... public void run{ ... java.sql.Connection con = ... I.E you fire your timer, do the random, which opens your connection. ...
    (comp.lang.java.gui)
  • Re: where should I dispose the connection ?
    ... Con variable points to the same connection object you created in ... connection was opened before closing it otherwise you'll get the exception ... Dim da As SqlDataAdapter ... >> Public Class Connection ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Row cannot be located for updating
    ... > result a recordset containing one row, ... > Strangly enough, the value that I changed, is changed in the database ... > Dim Con As New ADODB.Connection ... > 'Execute the query and remove the active connection ...
    (microsoft.public.data.ado)
  • Re: ADODB Woes - Please Help Me!
    ... > With Con ... Public Sub CloseRecordset ... Connection object itself is to be global, ...
    (microsoft.public.vb.general.discussion)
  • Re: ADO.NET problem
    ... As for commandbuilder, ... > Business1 calls connection class and gets a new connection. ... Now I pass this datarow to Business1. ...
    (microsoft.public.dotnet.framework.adonet)