How To Use SQL Svr 2005 Express In Excel 2003 VBA Code?
Jun 23, 2006
Hello,
how can I use SQL Svr 2005 Express as database engine in background through VBA code in Excel 2003?
I want to CREATE and DELETE tables and SELECT, INSERT and UPDATE data. Is it possible to use ADO or other database objects to get in contact with SQL Svr 2005 Express?
Hi, I need to import an SQL string from MS Excel 2003 to SQL SERVER 2000. The string I need to import is composed by 5 different several blocks and looks like:
The detail of the SQL string is at: http://forums.microsoft.com/msdn/showpost.aspx?postid=2093921&siteid=1&sb=0&d=1&at=7&ft=11&tf=0&pageid=1
I am trying to implement OJ's suggestion: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2117223&SiteID=1 to use multi - batch processing to import the string to SQL SERVER, something like:
Code Snippet Dim SqlCnt, cmd1, cmd2, cmd3 'set the properties and open a connection
cmd1="use my_db" cmd2="create table mytb" cmd3="insert into mytb"
I want to export Excell 2003 to Sql Server 2005. I am having the following error while execute the query.
declare @SQL varchar(8000) create table #temp(i int identity(1,1),SiteName varchar(100),SiteDescription varchar(5000),SiteURL varchar(500),CategoryName varchar(200)) set @SQL='Insert into #temp Select * From OPENROWSET (''Microsoft.Jet.OLEDB.4.0'',''Excel 8.0;Database=' + 'a.xls' +';HDR = YES;IMEX=0'',''SELECT * FROM [Sheet1$]'')'
exec (@SQL)
The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".
Hi all. I want to export data from excel 2003 to sql server 2005. I am using the following script: EXEC sp_configure 'show advanced options', 1; GO RECONFIGURE; GO EXEC sp_configure 'Ad Hoc Distributed Queries', 1; GO RECONFIGURE; GO Insert into Pamphlet Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:Pamphlet.xls;HDR=YES', 'SELECT * FROM [Sheet3$]') But it is giving the following error: Msg 7399, Level 16, State 1, Line 2 The OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)" reported an error. The provider did not give any information about the error. Msg 7303, Level 16, State 1, Line 2 Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)". The above script is working fine with Excel 2002 but not with 2003. Can someone please provide me exact script of importing data from excel 2003 to sql server 2005. I have also tried the Linked server option but it is still giving the same error. Please help me.
Is there a way to create a SQL 2005 x64 Linked server to an Excel (or Access) 2003/2007 file? In SQL 2005 32bit this was possible. Does anyone know of a solution or a work around?
I have around 600 worksheets that i need to import into sql server that are in a somewhat non-table like format. Data defractor seems to be able to do what i need, but i also need to check into doing it manually. I've seen the code to import cells and ranges into sql server, but can't seem to remember what it is anymore. I've also searched through the forums and can't seem to find any examples either. Could anyone post an example or a link with some examples or explaination code. Thanks in advance.
We are getting symptoms of a 30 second timeout irrespective of what we do, but only on certain machines. Can anyone shed any light on how the connection timeout can be set, as there seems to be a factor overiding any settings we set?
We are working in Excel (2003) connecting to an Analysis Services 2005 cube through a website https://Datasource connection. When we edit the connection string that the file is using (either by forcing use of an exterior .ODC file and editing the settings in there, or by converting the xls spreadsheet into an xml spreadsheet and manually editing the connection string in there) we get no joy: after 30 seconds the error appears:
"Either a connection cannot be made to the [my server address], or Analysis services is not running on the computer specified".
This error is itself rubbish: If a smaller query (one that takes < 30 seconds) is run in the same Excel file and Pivot Table, it connects fine. What really doesn't make sense is that the exact same file works on some machines and not others. These machines are all inside the same network (and the machines that work have been proven to work on a number of other networks). What's more there is no pattern to the machine capabilities - some newer / faster machines get the error. These machines (that work and do not) have excel 2003 SP3. (Another of the ones that works has Excel 2007).
Changing the connection string to include "Timeout=300" or "Connect Timeout=300" makes no difference, and "Command Timeout" causes a different error so that it wont even attempt to run the query (as opposed to collapsing after 30 seconds of normal progress). Similarly in the .ODV the tags <ODC:CommandTimeout>, <CommandTimeout>, <ODC:Connect Timeout>, <ODC:Command Timeout>, <meta name=CommandTimeout content=1000> etc. have no effect (the file still gets the 30 seconds error rather than just giving up so no way of working out correct syntax)
The only pattern we can see, and we can't fix this, is that the machines that work have Retail versions of excel, and the ones that do not have corporately licensed versions of excel. We cannot see any difference between them in the Help >Abouts, but thought it might be worth mentioning.
Any help would be fantastically appreciated, we are out of ideas. Thanks kindly
I have SQL Server 2005 Express running and I am creating a database through access (Access 2003 SP2) and no problem it creates the database...
But when I try to create other objects like views and database diagrams, I get the message below which is quite detailed but I just don't know where to get the service packs or updates needed to have this problem solved. Can anyone point out what the problem and the fixes are?
Here is the message that I get:
"This version of MS Office Access doesn't support design changes with the version of MS SQL Server your access project is connected to. See MS Office Update Website for the latest information and downloads (on the Help menu, click Office on the Web). YOur design changes will not be saved.
You have connected to a version of SQL server later than SQL Server 2000. This version of Visual Studio or Access that you are using was released before teh version of SQL Server to which you are connected. For this reason you might encounter problems.
Please check with MS to see if there is a service pack that you should apply to Visual Studio or Office in order to get support for the version of SQL Server to which you are connected.
You can continue but any new object types might not be enumerated, and it will not be possible to save any objects or database diagrams thatyou create using the Visual Database Tools."
I would really like to be using SQLServer Express 2005 for some desktop database applications and replace MSDE. However, I am using VS.NET 2003 and so far I have not been able to discover if that combination will work.
I am just starting to work with Visual Studio and SQL. I have Visual Studion 2003 with .net Framework 1.1. I want to download the SQL 2005 Express version and it requires the upgrade to .NET Framework 2.0
Will this affect my Visual Studio 2003? And can I use SQL 2005 with Visual Studio 2003?
Hi, I've a problem to install SQL Server Express 2005 on Win 2003 SP1. Do you know how to solve the problem ??
It displays error message after I click the setup file:
SQL Server Setup unexpetedly failed. For more information, review the Setup summary log file in %ProgramFiles%Microsoft SQL Server90Setup BootstrapLOGSummary.txt
Then I open the Summary.txt, it contains:
Microsoft SQL Server 2005 9.00.1399.06 ============================== OS Version : Microsoft Windows Server 2003 family, Standard Edition Service Pack 1 (Build 3790) Time : Thu Sep 21 11:17:18 2006
And review the SQLSetup0001_PCNAME_Core.txt in the Log Files directory:
Microsoft SQL Server 2005 Setup beginning at Thu Sep 21 11:17:18 2006 Process ID : 688 D:MasterSQLExpress2005setup.exe Version: 2005.90.1399.0 Running: LoadResourcesAction at: 2006/8/21 11:17:18 Complete: LoadResourcesAction at: 2006/8/21 11:17:18, returned true Running: ParseBootstrapOptionsAction at: 2006/8/21 11:17:18 Loaded DLL:D:MasterSQLExpress2005xmlrw.dll Version:2.0.3604.0 Complete: ParseBootstrapOptionsAction at: 2006/8/21 11:17:18, returned false Error: Action "ParseBootstrapOptionsAction" failed during execution. Error information reported during run: Could not parse command line due to datastore exception. Source File Name: utillibpersisthelpers.cpp Compiler Timestamp: Fri Jul 29 01:13:55 2005 Function Name: writeEncryptedString Source Line Number: 124 ---------------------------------------------------------- writeEncryptedString() failed Source File Name: utillibpersisthelpers.cpp Compiler Timestamp: Fri Jul 29 01:13:55 2005 Function Name: writeEncryptedString Source Line Number: 123 ---------------------------------------------------------- Error Code: 0x80070002 (2) Windows Error Text: The system cannot find the file specified.
Source File Name: cryptohelpercryptsameusersamemachine.cpp Compiler Timestamp: Mon Jun 13 14:30:00 2005 Function Name: sqls::CryptSameUserSameMachine::ProtectData Source Line Number: 50
2 Could not skip Component update due to datastore exception. Source File Name: datastorecachedpropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:49 2005 Function Name: CachedPropertyCollection::findProperty Source Line Number: 130 ---------------------------------------------------------- Failed to find property "InstallMediaPath" {"SetupBootstrapOptionsScope", "", "688"} in cache Source File Name: datastorepropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:50 2005 Function Name: SetupBootstrapOptionsScope.InstallMediaPath Source Line Number: 44 ---------------------------------------------------------- No collector registered for scope: "SetupBootstrapOptionsScope" Running: ValidateWinNTAction at: 2006/8/21 11:17:18 Complete: ValidateWinNTAction at: 2006/8/21 11:17:18, returned true Running: ValidateMinOSAction at: 2006/8/21 11:17:18 Complete: ValidateMinOSAction at: 2006/8/21 11:17:18, returned true Running: PerformSCCAction at: 2006/8/21 11:17:18 Complete: PerformSCCAction at: 2006/8/21 11:17:18, returned true Running: ActivateLoggingAction at: 2006/8/21 11:17:18 Error: Action "ActivateLoggingAction" threw an exception during execution. Error information reported during run: Datastore exception while trying to write logging properties. Source File Name: datastorecachedpropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:49 2005 Function Name: CachedPropertyCollection::findProperty Source Line Number: 130 ---------------------------------------------------------- Failed to find property "primaryLogFiles" {"SetupStateScope", "", ""} in cache Source File Name: datastorepropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:50 2005 Function Name: SetupStateScope.primaryLogFiles Source Line Number: 44 ---------------------------------------------------------- No collector registered for scope: "SetupStateScope" 00D3CFC8Unable to proceed with setup, there was a command line parsing error. : 2 Error Code: 0x80070002 (2) Windows Error Text: The system cannot find the file specified.
Source File Name: datastorepropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:50 2005 Function Name: SetupBootstrapOptionsScope.InstallMediaPath Source Line Number: 44
Class not registered. Failed to create CAB file due to datastore exception Source File Name: datastorecachedpropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:49 2005 Function Name: CachedPropertyCollection::findProperty Source Line Number: 130 ---------------------------------------------------------- Failed to find property "HostSetup" {"SetupBootstrapOptionsScope", "", "688"} in cache Source File Name: datastorepropertycollection.cpp Compiler Timestamp: Fri Jul 29 01:13:50 2005 Function Name: SetupBootstrapOptionsScope.HostSetup Source Line Number: 44 ---------------------------------------------------------- No collector registered for scope: "SetupBootstrapOptionsScope" Message pump returning: 2
I have been experiencing troubles since I was decided to install SQL Server Expr 2005 in my PC, first I needed to remove the .NET framework 1.1 in my computer because it is suggested before installing sql server expr 2k5 that cause my vs.net 2003 to stop loading because sql express runs in .NET framework 2.0 and vs.net 2003 is in .Net Framework 1.1 then what I did is to install .Net Framework 1.1 in my PC together with .Net Framework 2.0 and my vs.net started runnning again.
My problem now is when I try to connect to a database using Data Link Properties in the Server Explorer it says "[DBNETLIB][ConnectionOpen](Connect()).]Sql server does not exist or access denied." how could this happen if I can see the sql server in the Server Explorer in my VS.net environment?
Please somebody help me I am just learning to this language and I think I cannot proceed to the next few chapters remaining because of this.
I upgraded an Access 2003 database to SQL Server 2005 Express with the upsize wizard- worked great! Have a field that needs to be a hyperlink data type. There is no datatype in SQL that is hyperlink. Even if it were a text field, possibly inserting a hyperlink would work, but the insert hyplink in Access is unavailable, because the datasource is sql, maybe. I have a command button that ties to this function which won't work, obviously since it is not available. I need this field, it points to a file containing data that is being imported into the database. Huge piece of the database functionality. Making it easy for the user to find the file and using the vba to convert the data.
Saw the option of jump to url, but I don't think that will work? couldn't find the exact syntax either.
I have Visual Studio 2003 and had used it successfully with MSDE. I recently upgraded to SQL 2005 Express and cannot seem to connect to the SQL server. it appears in the list of servers on localhost, but when I try to create a new database it tells me that it "cannot create databases on this server." It will not even open up any existing databases.
I have .NET 2.0 installed. I uninstalled SQL and reinstalled it, but nothing seems to help. I feel I must be missing something, but do not know what.
I no longer have the MSDE installation files, so I hope I can get Studio to talk to SQL Express.
I have an Access 2003 project (sp2) and the data in SQL Server 2005 Express. My problem is when I try to make querys, diagrams, etc in Access, a warning tell me that I have installed a version of Access that is older than the version of SQL and all the designs that I make not be saved, and recommend a service pack for Access 2003 to correct the problem. Can anybody help me, where is this SP??
after successfully connect Access to the Server I want to add a table. I got an error message:
With this version of MS Office Access you are not able to make any drafts because this version of SQL server you are connected to does not support this. Check the MS Office update website for the newest downloads.
You habe connected to a version of SQL server which is newer than SQL server 2000.
Versions:
SQL Server runs on a MS Server 2003 SP1
Access 2003 (11.6566.6568 SP2) on an MS XP Pro SP1
all on actual patch level. Any ideas what's wrong?
Hi I am following a project to build a small E-Commerce site from a book I have purchased and I have having problems connecting to the SQL Database with the code supplied. The book is Apress Beginning ASP.NET 1.1 E-Commerce http://www.amazon.co.uk/Beginning-ASP-Net-1-1-E-Commerce-Professional/dp/1590592549/ref=sr_11_1/202-7684451-7995058?ie=UTF8&qid=1193780707&sr=11-1 The code added to the Web.Config file is : <configuration> <appSettings> <add key="ConnectionString" value="Server=(local)NetSDK;Integrated Security=True;Initial Catalog=JokePoint" /> </appSettings>
The connection details are in a class file called Catalog.vb and is as follows Imports System.Data.SqlClientPublic Class Catalog Public Shared Function GetDepartments() As SqlDataReader 'Create the connection objectDim connection As New SqlConnection(connectionString) 'Create and initialize the command objectDim command As New SqlCommand("GetDepartments", connection) command.CommandType = CommandType.StoredProcedure 'Open the connection connection.Open() 'Return a SqlDataReader to the calling functionReturn command.ExecuteReader(CommandBehavior.CloseConnection) End Function Private Shared ReadOnly Property connectionString() As String GetReturn ConfigurationSettings.AppSettings("ConnectionString") End GetEnd Property End Class The error is..... Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineNameASPNET'. 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.SqlClient.SqlException: Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineNameASPNET'.Source Error:
Line 15: 'Open the connection Line 16: Line 17: connection.Open() Line 18: Line 19: 'Return a SqlDataReader to the calling function Source File: C:MyCommerceSiteJokePointBusinessObjectsCatalog.vb Line: 17 Stack Trace:
[SqlException: Cannot open database "JokePoint" requested by the login. The login failed. Login failed for user 'MachineNameASPNET'.] System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) System.Data.SqlClient.SqlConnection.Open() JokePoint.Catalog.GetDepartments() in C:MyCommerceSiteJokePointBusinessObjectsCatalog.vb:17 JokePoint.DepartmentsList.Page_Load(Object sender, EventArgs e) in C:MyCommerceSiteJokePointUserControlsDepartmentsList.ascx.vb:44 System.Web.UI.Control.OnLoad(EventArgs e) System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Control.LoadRecursive() System.Web.UI.Page.ProcessRequestMain()
The connection tests ok in Visual Studio 2003. All permissions are set using SQL Management Studio Express 2005. The book is using SQL 2000, I have been trying different connection syntax's in the Web.Config file all day and now I have a big headache. I know its something simple, can anyone please advise ? Thanks in advance.
I've tried all I know in an effort to get SQL 2005 Express to allow remote connections on my customer's 2K3 server and I'm not having any luck. I've followed MSKB 914277, including adding the exceptions to their Windows firewall...even disabled the firewall altogether (for testing purposes), and I still can't get remote clients to connect. As suggested by various other posts, I used netstat -an to confirm that SQL is listening on port 1433 for the desired IP on the server.....and saw that it is listening. Here's a snippet:
TCP 192.168.0.2:1433 0.0.0.0:0 LISTENING TCP 192.168.0.2:1433 192.168.0.2:1738 ESTABLISHED TCP 192.168.0.2:1738 192.168.0.2:1433 ESTABLISHED TCP 127.0.0.1:1433 0.0.0.0:0 LISTENING
I can connect to the database locally (i.e. on the 2K3 server itself) using just the IP address .... tried with a DSN, UDL, ODBC, and SSMSE...all of which have no problems (as shown by the two, "ESTABLISHED" entries in the netstat results above which were from running SSMSE locally on the server at the time of the netstat). But if a remote computer on the network tries to connect, they cannot connect. Sorry, I don't have a copy of the error message the clients are getting yet.
I asked The customer's IT to confirm that the clients CAN can "see" the server (i.e. that there wasn't some kind of router or firewall blocking their path) and they sent me a copy of the server's pfirewall.log file. Here is an entry from the file that seems to show that client requests ARE getting to the server:
I'm starting to get in over my head here (I'm a programmer, not a DBA or Net Admin), but doesn't the above suggest that an incoming request came in from .4 on port 1213 and attempted to connect to .2 on port 1433, but the connection was denied or dropped by the server? If so, why? Is this related to another MS KB I read about connection pooling? I'm way over my head here and could use some help. Did I miss something subtle during configuration of SQL Express? Thanks in advance.
We are new to SQL Server 2005 Express Edition. We are going to develope a solution for one of our client and we have to decide on which database to use for the solution. Client wanted to have a low cost solution. Thus we were not in a position to push them for SQL Sever 2000.
In the process, we also thought of having MySQL as one of the option. Another option we have is to use SQL Server 2005 Express Edition.
We wanted to know if SQL Server 2005 Express Edition can be used with Visual Studion 2003 (Ver 1.1) or it can only be used with Visual Studio 2005 (Ver 2.0)?
I was wondering if it is possible to connect the SQL Server 2005 Express Version to Visual Studio 2003.If its possible , how can it be done?Cos i seem to have an error if i do so.
I Try to install SQL Server Express in Windows 2003 Standard edition x64 and have some problems.
It say that can not instal client and say to use sqlncli_x64.msi, but I can not find this packege to install this client and I receive one alert with ASP.NET register 64.
I Check all request systems requirements many times and looks ok.
How can I solve this to install properly the SQL 2005 Express? When the setup finish say that was not possiblem to install SQL Server 2005 Express.
I found about a dozen samples and articles in the net about inserting images in a sql database, but they were either using VB, or asp only or SQL 2000 and although I tried them all, none worked... Can you help me by posting some code on how to insert images in SQL 2005, using C# in Visual Studio 2005 (asp.net 2.0)
I am getting an sql Server 2005 connection error from c#.net 2005.
following is the error --------------------------------------------------------------------------------------------
{"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 have changed the default settings. local and remote connection are enabled.
following are the code i am using in C# .Net 2005 --------------------------------------------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient;
SqlConnection conn = new SqlConnection("server=localhost; user id= sa; pwd =; Initial Catalog=testdb;");
I'm new to using sql express 2005 as the database, so I apologize if my question is very basic.
I can connect to db through sql mngmt studio, but I don't know how to connect through application code. The authentication mode is windows. I'm having trouble with the provider in the application code.
Can someone please tell me where I can find more detailed information on available providers for sql express?
Thanks for any help, as I'm against a tight deadline.
hi guys, i am having a truble in accesing the server 2005 express edition from my client systems in server 2003 domain network. i get server not accessible. whereas my domain is working perfectly. i really tried alot and i have enable tcpip and named pipes and i am still getting errors while accessing. i have also created user reights for the domain users to access sql server. still i couldn't able to access it.
please guide me to over come this issue. I'm dying.My project is similar to SAP concept project and i am doing it in a production industry.so each department as to access the data from the server to update their daily production and activity.
Hi all, I have the following T-SQL code of Common Table Express (CTE) that works in the SQL Server Management Studio Express (SSMSE):
--CTE.sql--
USE ChemAveRpd
GO
WITH PivotedLabTests AS
(
SELECT LT.AnalyteName, LT.Unit,
Prim = MIN(CASE S.SampleType WHEN 'Primary' THEN LT.Result END),
Dupl = MIN(CASE S.SampleType WHEN 'Duplicate' THEN LT.Result END),
QA = MIN(CASE S.SampleType WHEN 'QA' THEN LT.Result END)
FROM LabTests LT
JOIN Samples S ON LT.SampleID = S.SampleID
GROUP BY LT.AnalyteName, LT.Unit
)
SELECT AnalyteName, Unit, avg1 = (abs(Prim + Dupl)) / 2,
avg2 = (abs(Prim + QA)) / 2,
avg3 = (abs(Dupl + QA)) / 2,
RPD1 = (abs(Prim - Dupl) / abs(Prim + Dupl)) * 2,
RPD2 = (abs(Prim - QA) / abs(Prim + QA)) * 2,
RPD3 = (abs(Dupl - QA) / abs(Dupl + QA)) * 2
FROM PivotedLabTests
GO
=========================================== How can I execute this set of the CTE.sql code in the VB 2005 Express via the Stored Procedure programming?