|
Sure, I've done it this way now.
It consists of two parts:
1) One InstallerClass that can copy files from the installation source directory to the target directory, replacing certain parameters in the process
2) Calling osql with the script created in step 1
The database files are included as regular files in the setup project and installed in a 'Database' subdirectory of the target directory.
Then I've added a custom action that, after all the files have been installed successfully, copies an sql template file to the target directory and fills in the real path to the database files.
Another custom action then calls osql -E -i <scriptCreatedInStep1> .
The script contents are just:
exec sp_attach_db @dbname='OurDatabaseName', @filename1='$(TRGDIR)\Database\MyDB.mdf', @filename2='$(TRGDIR)\Database\MyDB_Log.ldf'
go
and $(TRGDIR) gets replaced by the directory my program gets installed to.
Works great.
Regards,
mav
|
|
|
|
|
As an aside, you don't need to ship or attach the .ldf file. SQL Server will create one if you don't specify one as part of the sp_attach_db stored procedure. Might make the application slightly smaller when distributing it.
|
|
|
|
|
How could I use SQL/ASP to format a sting. I have the following:
10000 as a string - I would like to display it as 10,000 on my webpage.
Is this possible?
|
|
|
|
|
Try this:
NumberFormatInfo nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
int[] groupSizes = {3,3,0};
nfi.NumberGroupSizes=groupSizes;
nfi.NumberDecimalDigits=0;
someTextBox.Text = i.ToString("N",nfi);
The NumberFormatInfo and CultureInfo are both found in the System.Globalization namespace.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Whenever my ASP.NET page attempts to read an Access database, I get an exception stating that the workgroup file could not be found. When I open the database it works perfectly. Testing the data source from inside DreamWeaver MX 2004 also fails, but I believe that actually uses the web server to do the test.
Could this be because I haven't set up the workspace while logged in as the web user? What else could cause this to happen?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I have far away from .net for 4 month, but your question remind me when I use VB.net to connect to access database. Some techique need to specifies MDB file and MDW file. Then it will run properly. It it is possible, could you post your code here?
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
Komsot man from SCN-CO wrote:
techique need to specifies MDB file and MDW file. Then it will run properly. It it is possible, could you post your code here?
I would, but my code is at home and I'm at work . I'm using an OleDBConnection to make the connection. From memory, the connection string included the provider (Jet 4.0), file name, user ID and password. I think the rest of the code is fine because I copied it from a book, and DreamWeaver fails with exactly the same connection string. I assume their code is correct
Thanks for your help though
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
seems you just need to specify the WMD file path in the system database variable..
check :
http://www.able-consulting.com/ADO_Conn.htm
http://www.Connectionstrings.com
|
|
|
|
|
Thanks
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi,
I don't have ADOexpress from borland, but I want similar ADO components. I looked and found a few free ones, but only for Delphi. I found no free ones for C++ builder.
Does anyone know where to find what I am looking for?
Best wishes to all!
André
|
|
|
|
|
As I have this,
Dim CommandText2 As String = "Select SUM(PeriPrice) FROM Peripheral Where PCID='P0003'"
It sums up, and displayed "3399.000" on the datagrid.
But I want - 3,399.00.
Is there any way to do it?
Please help.
Thanks.
|
|
|
|
|
Select Right(Replicate('',10) + Convert(varchar(11),Convert(Decimal(10,2),SUM(PeriPrice))),11) FROM Peripheral Where PCID='P0003'
|
|
|
|
|
I dont' know if this is the right place, but someone please help.
When using ms soap in a vb macro I get this error, and I really don't know how to fix the damn thing:
"WSDLReader:XML Parser failed at linenumber 0, lineposition 0, reason is: Access is denied.
HRESULT=0x1: Incorrect function.
- WSDLReader:Loading of the WSDL file failed HRESULT=0x80070057: The parameter is incorrect.
- Client:One of the parametr supplied is invalid"
|
|
|
|
|
Hi,
I have this sql procedure that i need to run once every day.
Can anyone please tell me how can i do that.
Thanks
|
|
|
|
|
checkout documentation for sp_help_job and related stored procedures
|
|
|
|
|
Hi,
when using SQL Server 2000 one has the option of creating scriptfiles for all database objects, such as tables, sp's, views, users, roles, etc.
I need to write a tool which can perform the same thing and I need a starting point. Are there any ready made classes or libs out there? What SQL system-procedures are used to collect this information?
Any pointing appreceated.
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
All the information you need is in the system tables. These all start with 'sys' and exist in each database; The master database has extra tables that govern the whole server. The details of each of the system tables can be found in the books online.
There is also the INFORMATION_SCHEMA views which are on the master database. They use the system tables interally, so if you want to see how the systemp tables work then looking at the source for these views is quite useful.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Yes, Colin, it does help indeed (at leaster after recovering from the first shock)! Thanks very much!
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
Matthias Steinbart wrote:
at least after recovering from the first shock
Shock?! What was shocking?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
Not your answer, I just had a look at the system tables and estimated the amount of work it'll take to get a grip of this...
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
True, there are a hell of a lot of self referencial joins. I once ended up with one SELECT with about 8 joins - 3 of which were to sysobjects. Luckily I wasn't doing anything too complex. However, like I said, check out the definitions for the INFORMATION_SCHEMA views on the master database as they help a lot if you want to see examples of how it all hangs together.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
I have a lot of this done as part of a database build tool I am developing over on GotDotNet...
Check out the code in the "SQL Server Data schema providor" classes - shows how to list tables, views, users, user groups, stored procs and the fields, permissions, indexes etc. that apply to them.
|
|
|
|
|
CREATE PROCEDURE pr_InsertDictTable
@intID int,
@vchrValue nvarchar(50),
@vchrWesBarCode nvarchar(10),
@vchrTableName varchar(20)
AS
declare @sql varchar(1000)
set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+@intID+','+@vchrValue+','+@vchrWesBarCode+')'
print @sql
GO
Any problem in this procedure?
======
You need a head to program. Cool, fast and sharp.
|
|
|
|
|
set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+@intID+','+@vchrValue+','+@vchrWesBarCode+')'
->
set @sql = 'INSERT INTO ' + @vchrTableName + ' (Id, Name, PDACode) VALUES ( '+ CAST( @intID as varchar )+','+@vchrValue+','+@vchrWesBarCode+')'
|
|
|
|
|
Yes, plenty.
1. It's pointless. All you're doing is printing a string. Why not just generate the string at the caller?
2. variable @sql is not needed. you could just "print 'insert into ... "
3. It won't work. You need to CONVERT(varchar(10),@intid) before you can use it as a varchar.
4. You're mixing nvarchar and varchar. and implicitly casting nvarchar to varchar, thus negating the whole point of using nvarchar in the first place.
5. I think hungarian notation in a database is evil.
6. The main point of stored procedures is that they're compiled and hence more efficient. You're not leveraging that efficiency at all here.
jon
#include <beer.h>
|
|
|
|