DataSource Controls :: Bulkcopy Class For Oledb Like Sqlbulkcopy?
Mar 17, 2010I want to bulk insert the datatable data into database.I can not use sqlbulkcopy class.since,I am using oledb.
View 3 RepliesI want to bulk insert the datatable data into database.I can not use sqlbulkcopy class.since,I am using oledb.
View 3 RepliesI have an ASPNET application written in VB.NET which resides on the company's intranet. I am trying to do a bulkcopy from an excel file which is located in a secure folder on the web server to an existing table in Sql Server. The problem is that the folder requires a user name and password which is not the current logged in user or the ASPNET user. My question is how do I logon to the folder so that I can access the Excel file.
View 2 RepliesI'm using the SqlBulkCopy within my asp.net C# web form. I'm able to upload my excel file, but if the first row has any blank cells in it, that colum does not upload, I was wondering if anyone had any luck in looking for NULL/Blank cells and if so how did you handle them for the insert into the database?
View 6 RepliesI am confused by some behaviour I am experiencing when I use the SqlBulkCopy command.I have two tables in my SQL server database that I use to upload 2 tables of data from an excel workbook. The primary key of each table is customer account number, the first table being a table of accounts, the second being a table of details with the account number linking the 2 tables creating a one-to-one relationship.The bulk copy works a treat apart from one rather problematic situation I have found when performing error handling. If I put an account into the details table that does not appear in the customer table, instead of causing key violation errors it still adds the entry - I was under the impression that this was impossible?
If I go edit the entry using SQL Server management studio, I cannot change account numbers to anything that does not exist in the other table thus showing that the relationship exists and works when using standard update SQL.Does anyone have any idea why and how data that violates key violations is allowed through when I use SqlBulkCopy?
I code to exec a store procedre (sp_truncate) to truncate 10tables and using sqlBulkCopy to download a huge data. Both them are working fine.Now I want to use transaction with application (not in store procedure) torollback truncate tables if download is failed.Is it possible to use transaction to work with these two steps?
View 1 Repliesi am trying to create connection using OLEDB connection in my app. but i am not able to create the connection as in datasource i want to use Server.mappath, but cudn't find the right method to use it. i am trying to make connection with Access database file. following is code i have tried:
string path = Server.MapPath("~/uploadaccess/Production.mdb");
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb")&";";
and also
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path&";");
and tried this
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb"));
and this is the error i am getting:
Operator '&' cannot be applied to operands of type 'string' and 'string'
I'm using SqlBulkCopy to restore tables from xml backups. One of the table backup is ~200MB large and has a lot of records.
I'm having error:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I read a CSV file into a DataTable.The DataTable in the first image shows each column and type.The types are exactly what they are supposed to be and the data loaded all the rows it was supposed to load.From the second screen shot you can see the database table. SqlBulkCopy is supposed to map column names to database columns by default.According to that logic each column matches up exactly to the database and the column types also match.However,when I run the command it errors on the first row with:
"The given value of type String from the data source cannot be converted to type decimal of the specified target column."
Here is the StackTrace:
"at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata) at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternal() at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServer(Int32 columnCount) at
[code]...
Anyone have any ideas why this will not import correctly?
http://www.daviddelella.com/Images/Image1.jpg
http://www.daviddelella.com/Images/Image2.jpg
The attached code, the oledb part, is giving me a blank web page saying it cant connect on my local dev server. I have another app with the same code, in fact I copied it and changed the db names. The one I copied from works fine.
[Code]....
need a connection to only write records without using sql, i need to prepare my new table records and write it to the database in a single passage, im using oledb how is it done?
View 6 Repliesi am using my sql database. what type of data connection improve the performance.oledb connection or odbc connection ? what is the theory of these architectures?
View 8 Repliesi am trying to export a table from access database to excel sheet but i am facing error saying Type 'System.Data.OleDb.OleDbCommand' is not defined.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:Documents and SettingsUSERDesktopD0605data.accdb")
AccessConn.Open()
'New sheet in Workbook
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Excel 8.0;DATABASE=C:Documents and SettingsUSERDesktopD0605data1.xlsx;HDR=NO;].[Sheet1] from [Table1]", AccessConn)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
End Sub
End Class
I am attempting to use SqlBulkCopy to import data from an XML document. I receive the following error when executing WriteToServer: Invalid cast from 'System.String' to 'System.Guid'
View 1 RepliesI am using forms authentication and authorization through roleManager. I have two Roles - "Customers" and "Employees". The redirection to the default page for the "Customers" role is working fine, but I get an oledb error stating that one or more parameters are not being passed when I redirect a user from the "Employees" role. The following is the code in login.aspx that handles the authentication of the user:
If myReader.Read() Then ' We have a match
If myReader(1) Then ' This is true if an Employee and false otherwise
If Not Roles.IsUserInRole(logInUser.UserName, "Employees") Then
Roles.AddUserToRole(logInUser.UserName, "Employees")
End If
ElseIf Not Roles.IsUserInRole(logInUser.UserName, "Customers") Then
Roles.AddUserToRole(logInUser.UserName, "Customers")
End If
FormsAuthentication.RedirectFromLoginPage(logInUser.UserName, logInUser.RememberMeSet)
Else
Response.Write("Invalid credentials")
End If............................................
I am developing one web application using MS Access database using oledb connection.Previously i checked the same application is works well in the same machine.Now Today i checked they provide "Unspecified Error". And also Provide the following Exception:
System.Data.OleDb.OleDbException: Unspecified errorat System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection) at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open() at clsOledbClass.opencon() in c:inetpubwwwrootcheckNPCApp_CodeclsOledbClass.cs:line 64
I am using the following connection string for connecting database:
[Code]....
Error:
Executed as user: MACSTEELUSA.COMsa. ...9.00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 8:00:17 PM Error: 2010-06-02 20:00:18.56 Code: 0xC0202009 Source: CRM_ORACLE_ARSUMMARY Connection manager "SourceConnectionOLEDB" Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80004005 Description: "Oracle client
and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed.". End Error Error: 2010-06-02 20:00:18.58 Code: 0xC020801C Source: Data Flow Task Source - Query [1] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireCon... The package execution fa... The step failed.
Tasks Taken:Went to this folder checked for tnsnames.ora file but it is in good shape.
C:ORACLEproduct11.2.0client_1
etworkadmin
using sql server 2005 and vb.net 2005. I am writing a console application to import a mass amount of data from a non-sql database table into a sql server database table. The destination db table (sql server) has fewer tables than the source db table so I need to map the columns. does anyone have an example of how to do this?
View 1 RepliesI am really having a hard time trying to write something from scratch I created a 'Person' Class.Public Class Person
Private _FirstName As String = ""
Private _LastName As String = ""
Private _Age As Integer = 0
Public Sub New(ByVal FirstName As String, ByVal LastName As String, ByVal Age As Integer)
FirstName = FirstName
_LastName = LastName
_Age = Age
[code]...
I have been able to import an excel file sql bulkcopy locally. But when I publish the code to the server I get the following error messages:
Exception Message: 'C:MyTest.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Exception Source: Microsoft JET Database Engine
Here is code:
[code]....
i am using,Asp.net(vb),database sql server 2005, i want to use sysdsn DSN for database connection,so please Guide me how do i use DSN using web.config and class(we have sqlhelper type our own DBclass to set connectionstring for whole applicatoin. which get connection string from web.config),
Now,how do i use/set dsn in this type of scenario.
Why SqlDataReader Class object is not created by "new" Operator.
Is it not possible to create the object like below
SqlDataReader dr=new SqlDataReader();
dr=cmd.ExecuteReader();
Why the constructor of the SqlDataReader class is internal?
When I used the (way #1) below I could retrieve search result from my DB
Way #1:
[Code]....
But When I use( way#2) "separating my code to Presentation layer and data access layer ( using SQL HELPER CLASS )"
Way # 2
Presentation layer: protected void btn_Search_Advance_Click(object sender, EventArgs e)
[Code]....
data access layer:
[Code]....
I keep getting this error: Procedure or function 'SP_Search' expects parameter '@SEARCHTYPE', which was not supplied.
I have a webform whose ObjectDataSource reads an xml file to populate a GridView in the .aspx page. I have to hard code the file path in the .cs file defining the ObjectDataSource classes. I want to be able to use a portion of the query string to indicate which file to select, but, normal methods, like Server.MapPath and Http.Request.Current don't work in the class page. how I can pass values from the SelectParameters configured in the ObjectDataSource down to the ObjectDataSource method? Here is my Class code:
[Code]....
The filePath variable is what I want to be able to alter based on my query string.
string connectionString = (string)
ConfigurationSettings.AppSettings["ConnectionString"];
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("INSERT_PERSON",connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@Name",SqlDbType.NVarChar,50));
command.Parameters["@Name"].Value = txtName.Text;
command.Parameters.Add(new SqlParameter("@Age",SqlDbType.NVarChar,10));
command.Parameters["@Age"].Value = txtAge.Text;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
Above is my code.
I has more than 100 methods like this, so every time i'm opening the connection and close it, this will take too much of time, what i think is instead of this i would like to create the class for Connection open, that class will check whether the connection is closed or Broken then Open it(like SqlHelper.cs) so without big change on my methods, how to create that class and how to access that class from my methods.
i've created a dataset, and created inside it a datatable and its table adapter.
when i try to reference the table adapter in a .cs class i get an error message that i'm missing some namespace:
Compiler Error Message: CS0246: The type or namespace name 'DataSet1TableAdapters' could not be found (are you missing a using directive or an assembly reference?)