SQLDMO.BulkCopy
Jul 20, 2005
Hi all I am trying to do a Bulk Copy from a "tab delmimited" text file to a
table in my database. I have it almost working except when the file has
too few columns for the table (table has 421 columns).
Some of my the files will have 419 columns some others files will have 421
columns.
When my bulk insert script encounters a file with 419 colums it will put
some of the data from the next line in the last 2 columns.
I tried creating a DTS package with a bulk insert and I get the same out
come.
Here is my test script can anyone help
'--------------------------------------------------------------
<%
Dim objServer: Set objServer = Server.CreateObject("SQLDMO.SQLServer")
Dim objBCP: Set objBCP = Server.CreateObject("SQLDMO.BulkCopy")
Dim objDB: Set objDB = Server.CreateObject("SQLDMO.Database")
dim BulkCopy
dim objTable
dim item
dim g_strUploadPath: g_strUploadPath =Server.MapPath("../DOC2/")&"upload"
dim strFileName: strFileName = g_strUploadPath & "ex_test.txt"
'if file doesn't exist and it's an import,
'don't waste time (too be add later)
'If Import = True And Dir(FileName) = "" Then Exit Function
'On Error GoTo ErrorHandler
objServer.Connect "XXX.XXX.XX.XX", "XXX", "XX"
objServer.EnableBcp = 1
Set objDB = objServer.Databases("Advia120v2_dev")
With objBCP
.DataFilePath = strFileName
.UseBulkCopyOption = True
'tab delmitted, carriage return line feed ends row
.DataFileType = 2
'.ColumnDelimiter = chr(9)
'.RowDelimiter = chr(13) & chr(10)
.IncludeIdentityValues = False
End With
objDB.Tables("Hemo_193_39552_39").ImportData objBCP
'BCP = True
'ErrorHandler:
'Set objBCP = Nothing
'Set objServer = Nothing
%>
'--------------------------------------------------------------
thanks
View 3 Replies
ADVERTISEMENT
Dec 9, 2007
I use SQLDMO.Bulkcopy in an VB6 (have to) program to load data from aplain text file into a SQL Server 2000.One of the target columns is NOT NULL but it happens that I receive amissing value for that column in the source file. BulkCopy then has anODBC error raised that complains about the violated NOT NULLconstraint. The Bulkcopy error file however is empty. Is there a wayto figure out in which row of the source file the error occured ?Maybe a call to some ODBC diagnostics method to receive furtherinformation ? I'd like to avoid the obvious solution to drop theconstraint and then query the loaded data for NULL values.ThanksNils
View 3 Replies
View Related
Dec 8, 2007
Hi Folks,
Is there any effcent way of copy bulk records from SQL2000 to SDF ? The approach I am using at moment is manually concatenate insert CommandText based on the value datatable from SQL 2000. However, it's not very effcient and I am getting timeout on a table that has around 30 fields and 3,600 records.
Can any one think a better way of doing bulk insert on SDF? Both schema on SQL 2000 and SDF are exactly the same.
Thanks
View 8 Replies
View Related
May 9, 2007
Hello,
I am using bcp in a stored procedure. I am calling the stored procedure with VB.NET 2.0. The stored procedure does work, but not every time. I can run the stored procedure from Server Manager Express, and it does run, but not every time.
Here is my bcp command. Is this correct?
set @cmd = 'bcp '+@dbname+'.dbo.'+@tablename+' '+@direction+' '+@filepath+' -T -c -S .SQLEXPRESS'
exec master..xp_cmdshell @cmd
Thanks for any ideas on how to debug this.
Tom
View 5 Replies
View Related
Nov 11, 2007
I'm trying to use the SQL Bulk copy class to bulk import from a text file.I'm getting the following error: Line 24: bulkCopy.WriteToServer(CreateDataTableFromFile()); System.Data.SqlClient.SqlException: An error has occurred while establishing a
connection to the server. When connecting to SQL Server 2005, this failure may
be caused by the fact that under the default settings SQL Server does not allow
remote connections. (provider: Named Pipes Provider, error: 40 - Could not open
a connection to SQL Server) I've even tried to allow remote connections thro pipes and restarted the database engine but to no avail. Any inputs/suggestions?
View 3 Replies
View Related
Aug 22, 2005
Hi,I'm trying to find out if we can use bulkcopy via odbc in sql server 2005.With sql server 200 we could use the odbcbcp.dll.I can not find any info regarding this for ms sql server 2005.Thanks,Jos van der Velden
View 1 Replies
View Related
Feb 14, 2000
I am trying to write a database compare application for our SQL Server databases using VB and SQLDMO.
I find SQLDMO to be rather slow but on large databases with about 800+ tables, this loop eats up all of my abundant memory until everything crashes. On smaller db's it works fine but is a slower than I expected.
Dim Tbl as SQLDMO.Table
Dim Col as SQLDMO.Column
For Each Tbl in DB.Tables 'DB was previously set
For Each Col in Tbl.Columns
Debug.Print Tbl.Name & "." & Col.Name
Next Col
Next Tbl
Here's a pic of what the app looks like so far. If it looks useful to you, let me know, I'll give you a copy if I can get it working better!
Chad
View 1 Replies
View Related
Feb 5, 2006
I am using SQLDMO.DLL for Backup & restore utility in C# application.
Following is the code :
SQLDMO._SQLServer srv = new SQLDMO.SQLServerClass();
srv.Connect("IBM0505d-040","sa","");
SQLDMO.Restore res = new SQLDMO.RestoreClass();
res.Devices = res.Files;
res.Files = this.txtRestorefrom.Text;
res.Database = "abc";
res.ReplaceDatabase = true;
res.SQLRestore(srv);
While running above code it gives following exception :
"[Microsoft][ODBC SQL Server Driver][SQL Server]Database in use. The system administrator must have exclusive use of the database to run the restore operation.[Microsoft][ODBC SQL Server Driver][SQL Server]Backup or restore operation terminating abnormally."
Can somebody suggest solution for this.
Thanks,
Jitendra C.
View 1 Replies
View Related
Feb 8, 2006
Hi,
I am using SQLDMO for database backup and restore.
While taking a backup if I specify existing backup file name then I think it appends to existing file because its size increases almost by double.
And when I restore from that file the it restores data which I take back up very first time. It doest dont restores latest data.
If user specify existing file name then it should overwrite.
How to specify this using SQLDMO
Thanks
View 1 Replies
View Related
May 5, 2008
Hi all
Could anyone tell me from where i can find complete Documentation for SQLDMO Object and how can i initialize
and use it in my programms?
Kind Regards.
View 1 Replies
View Related
May 25, 2006
I have a program using SQLDMO object.When I use it on my computer and I have install sqlserverit works OK,but when I move the program to another computer without sqlserverthe program runs error the error message is com exception 80040154can the proram using SQLDMO running on computer without installing sqlserver?BTW: my System is win2003,and the other is windows xp
View 2 Replies
View Related
Feb 21, 2001
Hi
Are there sqldmo for server 6.5 ?, This is , the Sql server 6.5 has SQLDMO ?
View 1 Replies
View Related
Jun 8, 2006
Hi
I need to install sqldmo.dll and related files - so I can use SQL Objects. I've been searching the Internet and trying for hours to register the file on XP Client machines - but not go.
I have put the following files in the locations below:
sqldmo.dll Program FilesMicrosoft SQL Server80ToolBinn
sqldmo.rll Program FilesMicrosoft SQL Server80ToolBinnResources1033
sqlresld.dll Program FilesMicrosoft SQL Server80ToolBinn
sqlsvc.dll Program FilesMicrosoft SQL Server80ToolBinn
sqlsvc.rll Program FilesMicrosoft SQL
Server80ToolBinnResources1033
sqlunirl.dll System32
w95scm.dll Program FilesMicrosoft SQL Server80ToolBinn
I have also tried putting the files in System32 with the appropriate subdirectories - still not go. I cannot seem to get this to work.
If anybody has successfully installed sqldmo.dll for use on SQL Server 2000 client machines running XP, I'd be really grateful for a few pointers.
Thanks
Paul
View 2 Replies
View Related
Apr 24, 2008
can anyone give the registry key for sqldmo.dll?
View 1 Replies
View Related
Dec 18, 2006
jess writes "Hi,
IS there a component/way of retrieving a list of SQL Servers or databases on your local network for SQL 2005/Express. The same way sqldmo worked for a .net project.
thanks"
View 1 Replies
View Related
Sep 8, 2005
Hi,how to create an SQL DMO object in .net and use it to enumerate theproperties of Sql server. Can we use this object to list propertieswithout logging in to the server?
View 3 Replies
View Related
Jul 20, 2005
Using InstallShield Developer 7.04.Does anyone know of a good way to detect if SQLDMO is installed?TIAmcpoo
View 2 Replies
View Related
Jan 22, 2004
Hello all,
has anyone had the opportunity to try the sql web admin tool? if so, i have one question.
How can i use this to connect to a remote sql/msde server?
in the server textbox on the login screen i try 'machine name''instance name', along with the sa username and password. This does not work however.
am i just entering the wrong value , or do i need to change the code of the .connect method to allow for remote connections?
TIA.
-C-
View 1 Replies
View Related
May 11, 2004
Hi,
I need to access and read the transaction log and run an update according to the log....is it possible through sqldmo....is there any other methods through which i can do the same
View 1 Replies
View Related
Apr 28, 2005
Problem is: "I am trying to attach a database through SQLDMO using VB6 In MSDE (Microsoft Sql Server Desktop Engine). If my '.mdf' and '.ldf' files are placed in a folder with Spaces then it give me error because it is picking up the folder name up to first space."
View 1 Replies
View Related
Feb 23, 2006
In VS 2003 I used SQLDMO (Com Object) to list all available SQL Servers. Is in SQL Server 2005 a managed .net Component that can do that task?Thanks,Rainer.
View 2 Replies
View Related
Jun 25, 2001
I have a question regarding using SQLDMO.Backup.
I am finding that if the Files property specifies a folder for the path & filename that contains a space, the SQLDMO object appends a path of C:Program FilesMicrosoft SQL ServerMSSQLBackup and then my path.
If I use a path like C:TempBackup all works ok.
How do I get SQLDMO to accept a path with a space in the definition.
Thanks
View 2 Replies
View Related
Oct 8, 2001
Hello,
Does anyone know how I add the SQLDMO library to enable me to reference it in DTS Active X scripts? I do not want to install VB on the server to do this.
Regards,
John Thorpe
View 1 Replies
View Related
Jul 23, 2005
I have code that instantiates a sqlserver object and starts a job. Ihave used this on numerous XP workstations successfully, when I triedto move this to a Windows 2000 Application Server attached to a SmallBusiness Windows 2003 network and run the code, I am receiving theerror:Automation Error. The Operating System Cannot Run %1.(Error Number -2147024714)The following is a code snippet:*********Dim app As New SQLDMO.ApplicationDim oSQLServer As New SQLDMO.SQLServerDim oJob As SQLDMO.JoboSQLServer.LoginTimeout = 30 ' ERROR OCCURS HEREoSQLServer.LoginSecure = True**********The code fails when setting the LoginTimout parameter. The SQLDMO.dllhas been registered successfully on the server.Any ideas whey the behavior of this code is different on my applicationserver vs the client workstations on the network?ThanksMike G
View 2 Replies
View Related
Jul 23, 2005
My application uses sqldmo to retrieve the list of sql servers in thenetwork, it works fine in some machines, but it is crashing theapplication in others, no error and no exception, it shuts down theapplication. It fails in the following line:SQLDMO.NameList sqlServers = sqlApp.ListAvailableSQLServers();any ideas?thanksmusachy
View 2 Replies
View Related
Jun 20, 2006
Hi,I am new to the mysteries of SQLDMO.I have written a program whereby the user can select which SQL serverto connect to on the Network and this works fine.I am using the SQLDMO.Application.ListAvailableSQLServers routine andthis works fine.However, the Server on the users machine appears as 'Local'I need to display the server name as the actual server name instead of'Local'Any ideas how to do this with SQLDMO.I know I could delve into the registry and get the name from there, butI want to avoid this.CheersAlex
View 2 Replies
View Related
Feb 4, 2008
Hi, this is a bit of background to what I'm trying to achive:
I have an application that creates a new database in MS 2000. The application will then create a login, with then create a user and add the login to the user, it will then add that user to the folling roles; db_owner, db_datareader, db_datawriter.
A SQL script is then run to add tables, view and stored procedures to the new database.
Most of this works however I'm having a few problems with loging in as the new user. Aslo how do I ensure that if new objects (tables, stored procs etc) are added the new user will have full permissions on them?
This is the code I have so far...I'm going round in circles with it and was hoping that someone with fresh eyes might be able to see where I'm going wrong:
Many thanks
1 protected string CreateUser(string strDatabaseName)
2 {
3 //database hase alreday been created
4 SQLDMO.SQLServer gSQLServerDMO = new SQLDMO.SQLServer();
5
6 string serverName = ConfigurationManager.AppSettings["DbsServerName"];
7 gSQLServerDMO.Connect(serverName,
8 ConfigurationManager.AppSettings["DbsUserName"],
9 ConfigurationManager.AppSettings["DbsUserPwd"]);
10 //get the database object
11 SQLDMO.Database dbs = (SQLDMO.Database)gSQLServerDMO.Databases.Item(strDatabaseName, "");
12
13 #region create a login object and populate it
14 SQLDMO.Login login = new SQLDMO.Login();
15 string loginName = strDatabaseName + "_WebLogin";
16 login.Name = loginName;
17 string password = "password";
18
19 login.SetPassword("", password);
20 login.Database = strDatabaseName;
21
22 //check if it exists
23 bool found = false;
24 foreach (SQLDMO.Login ologin in gSQLServerDMO.Logins)
25 {
26 if (ologin.Name == loginName)
27 {
28 found = true;
29 break;
30 }
31 }
32 if (!found)
33 gSQLServerDMO.Logins.Add(login);
34 #endregion
35
36 #region create the user
37 SQLDMO.User user = new SQLDMO.User();
38 //assign the login
39 string userName = strDatabaseName+ "_WebUser";
40 user.Name = userName;
41 user.Login = loginName;
42 //dbs.Users.Add(user);
43
44 found = false;
45 foreach (SQLDMO.User oUser in dbs.Users)
46 {
47 if (oUser.Name == loginName)
48 {
49 found = true;
50 break;
51 }
52 }
53 if (!found)//add the user to the dbs
54 {
55 dbs.Users.Add(user);
56
57 //add user to role
58 //db_owner
59 //SQLDMO.DatabaseRole oRole = new SQLDMO.DatabaseRole();
60 //oRole =
61 //oRole.AddMember(loginName);
62 dbs.DatabaseRoles.Item("db_owner").AddMember(userName);
63 dbs.DatabaseRoles.Item("db_datareader").AddMember(userName);
64 dbs.DatabaseRoles.Item("db_datawriter").AddMember(userName);
65 }
66 #endregion
67
68 string connString = "server=" + serverName + ";database=" + strDatabaseName + ";uid=" + userName
69 + ";pwd=" + password + ";";
View 1 Replies
View Related
Dec 14, 2001
Hi,
I run into a problem which I cannot connect to the database using SQL Server 2000 Enterprise Manager. The SQL Server 2000 was working well until I hook a SQL Server 7.0 application to it. The error message: "General OLE Error 16386, You must upgrade your SQL Enterprise Manager & SQL-DMO (SQLOLE) to SQL Server 2000 (SQLDMO) to connect to this server". I checked fixed in the sp1 for SQL Server 2000, and found no entry. In MS support website and found nothing. Need help from someone who has experience on this. Thanks in Advance.
Eugene
View 1 Replies
View Related
Feb 19, 2008
Hi,
I developed an application in Vb.net and SQLDMO that backs up a database and performs certain operations on it once this is done. I have set the backup to backup to file which the user selects. However when i execute the backup i get an error message that " Backup device not found or error finding device" .THis error baffles me because i have not specified the backup to be to device can anyone help?
View 14 Replies
View Related
Jan 26, 2006
I created a SQL Server Project in VS 2005, and tried to add a reference to SQLDMO Object dll. But the reference --> add reference, does not allow it. It does not work, even if I set the Assembly Permission Level to UNAFE/EXTERNAL ACCESS.
Reason I'm trying to do this:
We have a SQL 2000 stored procedure that uses SQLDMO using sp_OACreate to BCP files to database. We are converting to 2005 and because of SOX restrictions, I'm trying to replace the sp_OACreate part with external stored procedure written in C#.
According to BOL, I thought atleast UNSAFE should support this, but it seems not.
Probably, I'm expecting too much..
Your help is greatly appreciated.
Thanks
View 1 Replies
View Related
Apr 17, 2008
We are having a Windows Installer Program (32 bit) which calls the SQLDMO to get the list of installed instances in a 64 bit 2005 sql server machine. This fails as the windows installer tries opens up the 32 bit sqldmo and there is no instance of 32 bit sql server on this machine.
Is there any way by which sqldmo can return all 64 bit sql server instance when called from a 32 bit Application?
Regards,
Ashish
View 4 Replies
View Related
Jun 19, 2006
hi
i have a project and i want make thats;
1-)The list All SQL Server(s) in my network to dropdrown list(that's ok)
2-) the list all databases to selected sqlserver(that's ok)
3-) the list tables to selected database(i cant)
i wrote my source kod please help me
1-)
Dim mDMOApp As New SQLDMO.Application
Dim mNames As SQLDMO.NameList
Dim t As Integer
mDMOApp = New SQLDMO.Application
mNames = mDMOApp.ListAvailableSQLServers()
lstServers.Items.Clear()
For t = 1 To mNames.Count
lstServers.Items.Add(mNames.Item(t))
Next
2-)
Dim server As New SQLDMO.SQLServer
Dim db As SQLDMO.Database
server.Connect(mysqlserver, "xxx", "xxx")
For Each db In server.Databases
lst.Items.Add(db.Name)
Next
3)
how can i ???
View 2 Replies
View Related
Jan 10, 2001
I am a new SQL Server developer using Visual Basic 6 Professional Edition. I am using ADO and SQLDMO to develop my application. The SQL Server is Version 7.0, SP2 and SP3 (two different servers).
I am having difficulty gaining access, using ADO, to databases I create using SQLDMO. I create the database, create the DBFILE object, create a login and attach it to the database, create a user, assign the created login to the user,
and assign the created user to the 'db_datareader', 'db_datawriter' and 'public' roles. the login object was set to 'standard', not NT. the SQL Server is set to 'mixed' NT -SQL Server login mode. Thw SQL Server is running under the 'system account'. Using SQL Server Enterprise Manager, everything looks OK. An attemp to connect using the ADO connection object fails, giving an error of Login failed for user 'engbom3admin'.
Connecting to the SQL Server using SQLDMO uses the 'sa' user name with a blank password.
I can successfully connect to the created database using the ADO connection object using the 'sa' user name and blank password. Using the SQL Server Enterprise manager, I cannot see anything at all different between the 'sa' and my created 'engbom3admin' user. I've manually set the created user to have 'db_owner' roles, etc. Same result. I'm stumped. I've read all I can gather from the Microsoft SQL Server books. I'm still stumped.
I would greatly appreciate any help, information or tips you could provide. Thank you in advance.
Sincerely,
Bob Wohlers
SVP, IS Datamax Corporation
View 2 Replies
View Related