 |
|
 |
This works, i have use this to insert xml data to ms access thanks
|
|
|
|
 |
|
|
 |
|
 |
While filling the dataset you need to set the "AcceptChangesduringFill" property to false. Then this would work fine.
Hope this helps.
Thanks,
mr26
|
|
|
|
 |
|
|
 |
|
 |
its not a bulk insert... its simple insert.
|
|
|
|
 |
|
 |
Hi I have The Following Code. Can you help me spot the problem as the table does not update.
Thanks.
readdbsettings();
OleDbConnection msaConn = new OleDbConnection(msaconstr);
DataTable DT = new DataTable();
string sql = "";
string msql = "";
string minsert = "";
// Do MSSQL
if (dbtype == "SQL")
{
conSQL1 = new SqlConnection(sqlconStr);
conSQL1.Open();
sql = "select 'Prod' as release_type, product as sage_code, description, abc_category as category_a, "+
"' ' as category_b from scheme.stockm";
SqlDataAdapter sqlda = new SqlDataAdapter(sql, conSQL1);
sqlda.Fill(DT);
conSQL1.Close();
}
// Do Informix
if (dbtype == "INF")
{
}
//Write to rules table
msql = "SELECT * FROM release_rules WHERE 0=1";
minsert = "INSERT INTO release_rules (release_type, sage_code, description, category_a, category_b) " +
"VALUES (@prelease_type, @psage_code, @pdescription, @pcategory_a, @pcategory_b) "; //+
//"where @sage_code not in " +
//"(select sage_code from release_rules where sage_code = @sage_code); ";
OleDbDataAdapter OleAdp = new OleDbDataAdapter(msql, msaConn);
OleAdp.InsertCommand = new OleDbCommand(minsert);
OleAdp.InsertCommand.Parameters.Add("@prelease_type", OleDbType.VarChar, 255, "release_type");
OleAdp.InsertCommand.Parameters.Add("@psage_code", OleDbType.VarChar, 255, "sage_code");
OleAdp.InsertCommand.Parameters.Add("@pdescription", OleDbType.VarChar, 255, "description");
OleAdp.InsertCommand.Parameters.Add("@pcategory_a", OleDbType.VarChar, 255, "category_a");
OleAdp.InsertCommand.Parameters.Add("@pcategory_b", OleDbType.VarChar, 255, "category_b");
OleAdp.InsertCommand.Connection = msaConn;
OleAdp.InsertCommand.Connection.Open();
OleAdp.Update(DT);
OleAdp.InsertCommand.Connection.Close();
|
|
|
|
 |
|
 |
Hi Again
I have found the problem at last.
The Access Table had a primary key for the sage code. Now I just have to figure out how to get rid of the duplicates
Thanks
|
|
|
|
 |
|
 |
sir,i made simple program to insert data in table,it shows the problem that operation must be updateable query.it works well on
local computer but i load on Internet website it shows error that it must be updateable query.
Please help me.i shall be very thankful to you
My Code is as follows:
OleDbConnection conn;
OleDbDataAdapter dataAdapter;
DataSet ds;
string cs;
conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source="+
Server.MapPath("db1.mdb"));
conn.Open();
cs="INSERT INTO trader(name)values(@firstname)";
OleDbCommand dc=new OleDbCommand(cs,conn);
OleDbParameter fparam=new OleDbParameter("@firstname",OleDbType.VarChar,10);
fparam.Value=TextBox1.Text;
dc.Parameters.Add(fparam);
dc.ExecuteNonQuery();
conn.Close();
|
|
|
|
 |
|
 |
I was wondering if there is any way to allow the Update method to occur more than once? I'm writing an application and this has been very helpful so far, but I have to call UpDataDB more than once and it seems that it will not work again no matter how I arrange the datatables and access tables. Any help please?
great work , thanks
|
|
|
|
 |
|
 |
Nevermind, I realized that this is only and Update to changed rows.
|
|
|
|
 |
|
 |
im using folowing code but it is not inserting to database. im selecting from a csv file and then filling dataset object with selected data.
its selecting data from csv file but not inserting to access database...any suggestion plz
string ConnString = "connection string";
string SQL = "SELECT * FROM allSheetsData WHERE ID = 0 ";
string INSERT = "Insert into allSheetsData " +
" (symbol, Series, BhavDate, open, close, low, high, tottrdqty)" +
" VALUES (@sSymbol, @sSeries, @sTimeStamp, @sOpen, @sClose, @sLow, @sHigh, @sTottrdQty)";
OleDbConnection OleConn = new OleDbConnection(ConnString);
OleDbDataAdapter OleAdp = new OleDbDataAdapter(SQL, OleConn);
OleAdp.InsertCommand = new OleDbCommand(INSERT);
OleAdp.InsertCommand.Parameters.Add("@sSymbol", OleDbType.VarChar, 255, "SYMBOL");
OleAdp.InsertCommand.Parameters.Add("@sSeries", OleDbType.VarChar, 255, "SERIES");
OleAdp.InsertCommand.Parameters.Add("@sTimeStamp", OleDbType.VarChar, 255, "TIMESTAMP");
OleAdp.InsertCommand.Parameters.Add("@sOpen", OleDbType.VarChar, 255, "OPEN");
OleAdp.InsertCommand.Parameters.Add("@sClose", OleDbType.VarChar, 255, "CLOSE");
OleAdp.InsertCommand.Parameters.Add("@sLow", OleDbType.VarChar, 255, "LOW");
OleAdp.InsertCommand.Parameters.Add("@sHigh", OleDbType.VarChar, 255, "HIGH");
OleAdp.InsertCommand.Parameters.Add("@sTottrdQty", OleDbType.VarChar, 255, "TOTTRDQTY");
//==============================
OleAdp.InsertCommand.Connection = OleConn;
OleAdp.InsertCommand.Connection.Open();
OleAdp.Update(DT);
OleAdp.InsertCommand.Connection.Close();
|
|
|
|
 |
|
 |
It looks like it is setup right.
I would make change 'Insert into' to all caps 'INSERT INTO'.
rajinder s wrote: " (symbol, Series, BhavDate, open, close, low, high, tottrdqty)" +
If they are lower case here ^^^^^^^ make sure you put them in lower case below vvvvv.
rajinder s wrote: OleAdp.InsertCommand.Parameters.Add("@sSymbol", OleDbType.VarChar, 255, "SYMBOL");
OleAdp.InsertCommand.Parameters.Add("@sSeries", OleDbType.VarChar, 255, "SERIES");
OleAdp.InsertCommand.Parameters.Add("@sTimeStamp", OleDbType.VarChar, 255, "TIMESTAMP");
OleAdp.InsertCommand.Parameters.Add("@sOpen", OleDbType.VarChar, 255, "OPEN");
OleAdp.InsertCommand.Parameters.Add("@sClose", OleDbType.VarChar, 255, "CLOSE");
OleAdp.InsertCommand.Parameters.Add("@sLow", OleDbType.VarChar, 255, "LOW");
OleAdp.InsertCommand.Parameters.Add("@sHigh", OleDbType.VarChar, 255, "HIGH");
OleAdp.InsertCommand.Parameters.Add("@sTottrdQty", OleDbType.VarChar, 255, "TOTTRDQTY");
Give that a try.
God Bless,
Jason
Programmer: A biological machine designed to convert caffeine into code. Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
 |
|
 |
I am trying to connect to Access database, I am creating ASP.NET login page using c# 2003 code behind, I keep on getting this error when trying to connect to my database:
[Server Error in '/BookFlight' Application.
--------------------------------------------------------------------------------
No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D).
Source Error:
Line 116:
Line 117: if(oleDbConnection1.State == ConnectionState.Closed)
Line 118: oleDbConnection1.Open();
Line 119:
Line 120: //while (dataReader.Read())
Source File: c:\inetpub\wwwroot\bookflight\login.aspx.cs Line: 118
Stack Trace:
[OleDbException (0x80040e4d): No error information available: DB_SEC_E_AUTH_FAILED(0x80040E4D).]
System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr)
System.Data.OleDb.OleDbConnection.InitializeProvider()
System.Data.OleDb.OleDbConnection.Open()
BookFlight.WebForm1.CustomValidator1_ServerValidate(Object source, ServerValidateEventArgs args) in c:\inetpub\wwwroot\bookflight\login.aspx.cs:118
System.Web.UI.WebControls.CustomValidator.OnServerValidate(String value)
System.Web.UI.WebControls.CustomValidator.EvaluateIsValid()
System.Web.UI.WebControls.BaseValidator.Validate()
System.Web.UI.Page.Validate()
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032 ]
the line oleDbConnection1.Open(); is highlighted in red, Is there some problem with my connections?
Please help.
Kholiwe
|
|
|
|
 |
|
 |
if you don't mind will you place the codebehind class that this is referring to. That way I can see how you have set up the OleDb object. Remember after you copy and paste it into the window, highlight the code for the class and then click the 'code' button or wrap it with
God Bless,
Jason
Programmer: A biological machine designed to convert caffeine into code. Developer: A person who develops working systems by writing and using software.
[ ^]
|
|
|
|
 |
|
 |
There is actually a more generic way of SELECTing an empty data set that will return the headers:
SELECT * FROM TABLENAME WHERE 0=1
This method works with any table and the where clause guarantees that no records will be returned.
|
|
|
|
 |
|