|
Hi.
This is a general discussion post, that i've posted in the System Administration forum as well.
I've come to a point where i have a finished ASP.NET web application that i want to distribute. It use ASP.NET web as a front-end, .NET Windows as a front-end for the SQL Server backend db.
I want to create some sort of installation package for my application. I should do the following things:
1) Create FTP login
2) Create Virtual Directory in IIS
3) Copy ASP.NET files to virtual directory
4) Duplicate SQL database
5) Update web.config file in ASP.NET app.
At the moment i have some issues on point 4. What is the best approatch on duplicating SQL server databases programaticly. Are there any pre-made serverinstaller packages? Got any good articles/guitlines on the subject?
In general, i need some info on what is the best approatch to take when distributing a server app.
-Jonas
|
|
|
|
|
Server installation packages usually script out the database objects to a sql script file and bcp the necessary data out to a bcp file. When the installation is run on the target server, this script file is applied to the target database and the data bcp'd back into the target database.
It's also a good idea to let the DBA of the server database review the script file before installation so that he knows what's being done to his database server.
|
|
|
|
|
I using ADO to execute a stored procedure that will return a recordset and some parameters, but if I get the recordset will cause output parameters to be empty.
rs = cmd->Execute( NULL, NULL, NULL );
otherwise, I remove rs then the output parameters will be right.
cmd->Execute( NULL, NULL, NULL );
any idea?
|
|
|
|
|
For SQL-Server, the output parameters are only available after you have closed the recordset.
|
|
|
|
|
Hi
I have a problem with one of my fields in a table.
whenever the value of this field is going to be showed it must be converted to some other value .and when the user inserts a new value (in the second format, because the user knows nothing about the real format of the field) it must automaticly be converted to
the first format before saving.
In Delphi I do it with GetValue and SetValue Events of each field. But in .Net environment I don’t know how can I do that.
Thanx.
With best regards
|
|
|
|
|
I am doing a project in SQLJ and have the source as below:
This code will construct a tree structure from two SQL query using the connect by ... PRIOR statements.
The first SQL query will create the parent.
The Second SQL query will create the childern based on the parent value.A parameter is passed from Query1 to Query2 to establish a relationship between the parent and the child.
My problem now is to construct a Tree using JTree in java based on the above results of the SQL query.i,e the parent & children hierarchy has to be the same. I have tried to use a Hashtable but I am finding it vey difficult.IF SOMEONE HAS A SOLUTION, PLEASE HELP ME WITH AN EXAMPLE.
import java.sql.SQLException;
import oracle.sqlj.runtime.Oracle;
import sqlj.runtime.ref.DefaultContext;
import java.util.*;
#sql iterator iter1(String id,String fdn,int level);
#sql iterator iter2(String clli);
public class GetTree2
{
public GetTree2(String user_name,String password) throws SQLException
{
new TpSess1(user_name,password);
{
usingNamed();
}
finally
{
Oracle.close();
}
}
public GetTree2() throws SQLException
{
new TpSess1();
try
{
usingNamed();
}
finally
{
Oracle.close();
}
}
public static void main(String args[]) throws SQLException
{
new GetTree2(args[0],args[1]);
}
public void usingNamed() throws SQLException
{
iter1 it1=null;
iter2 it2=null;
String temp=null;
String pare1=null;
String par2=null;
String pare3=null;
String strcll1=null;
String strcll2=null;
String strcll3=null;
Vector all = new Vector();
Hashtable lev1 = new Hashtable();
Hashtable lev2 = new Hashtable();
Hashtable lev3 = new Hashtable();
Hashtable lev4 = new Hashtable();
Hashtable cll1 = new Hashtable();
Hashtable cll2 = new Hashtable();
Hashtable cll3 = new Hashtable();
Hashtable cll4 = new Hashtable();
#sql it1={select id,fdn,level from groups connect by prior fdn=parent_fdn
start with fdn='/' };
while(it1.next())
{
all.addElement(it1.id());
switch(it1.level())
{
case 1: lev1.put(all.elementAt(0),it1.id());
pare1 = it1.id();
break;
case 2: lev2.put(pare1,it1.id());
par2 = it1.id();
break;
case 3: lev3.put(par2,it1.id());
pare3 = it1.id();
break;
case 4: lev4.put(pare3,it1.id());
break;
}
temp=it1.fdn();
#sql it2= {select clli from nes where parent_fdn=:temp order by clli };
while(it2.next())
{
switch(it1.level())
{
case 1: cll1.put(all.elementAt(0),it2.clli());
break;
case 2: strcll2 = it1.id();
cll2.put(strcll2,it2.clli());
break;
case 3: strcll3 = it1.id();
cll3.put(strcll3,it2.clli());
break;
case 4: strcll4 = it1.id();
cll4.put(strcll4,it2.clli());
break;
}
}
}
it1.close();
it2.close();
}
}
|
|
|
|
|
Parameters.Refresh() method created all parameters that are stored process provide. but I can't obtain the value of output parameter after execute.
Thank you very much.
|
|
|
|
|
Hi,
Our company writes simulation and optimisation software. Because of that, we need:
1. a consistent view of the data
2. fast access to the data
Therefore all relevant data is loaded from the database at once, and all optimisation and simulation is performed on the data in memory.
We do this since the late 80s on databases like Vax/Rdb, Ingres and Oracle. All of these databases offer the possibility of starting a Read-Only Transation, i.e. all queries performed in the transaction 'see' the data like it was at the start of the transaction, even if it was modified by some other user in the mean time.
We are now considering Microsoft's SQL Server, but apparently it does not offer the possibility of Read-Only transactions. This means that if our application starts up and wants to load all relevant data of the database, it has to use a 'serializable' transaction (actually putting a Read lock on all the tables) to be sure that consistent data is read.
This means that:
- during a start-up, nobody can save
- during a save, nobody can start-up
I'm stunned to see that SQL Server does not offer Read-Only transactions.
Probably most of the [database] world is developing OLTP-type applications, but somewhere there must be somebody writing applications that need to load big parts of the database.
How do these people solve that problem?
Did anybody encounter this problem also and has found a solution for it?
Thanks in advance.
Enjoy life, this is not a rehearsal !!!
My Articles:
- Implementing a Subject/Observer pattern with templates
- Different ways of writing class factories
- AutoRunner: a template class to automatically run start- and cleanup-code in code blocks
</
|
|
|
|
|
It looks like you need to search in Books Online for Transaction Isolation Levels. More specifically, the SERIALIZABLE isolation level that prevents dirty reads.
|
|
|
|
|
|
Working with a table containing 2 million records I want to get the last record for each group.
Example: <br />
ID Field1 Field2 Field3 DateEntered<br />
1 tom a b 12/12/00<br />
2 tom b c 1/1/01<br />
3 jack d e 2/2/01<br />
4 tom d e 1/2/02<br />
5 me a d 1/2/02<br />
6 jack a b 2/2/02<br />
7 me d d 3/3/03
I want to get only IDs 4, 6 and 7, because they are the last orders for tom, jack and me. Because of the size of the table using a cursor is out of the question. Anyone know of a good way this can be done.
Thanks,
Jason W.
|
|
|
|
|
SELECT a.* from Table1
INNER JOIN
(SELECT field1, max(dateentered) AS zDateEntered
FROM table1
GROUP BY field1)
b
ON a.field1 = b.field1 and a.DateEntered = b.zDateEntered
|
|
|
|
|
Very nice… That’s exactly what I was looking for thanks.
Jason W.
|
|
|
|
|
Hi All,
I’m handling events of ADO in an ATL out-of-process server, and for some reasons when I use _ATL_FREE_THREADED declaration event ConnectComplete is not called when I establish an asynchronous connection, thou it is called when I use a synchronous connection. Changing the memory model to _ATL_APARTMENT_THREADED solves the problem, but what is the reason of such strange behaviour anyway, and what’s the
proper solution?
Regards,
Vitaly Tomilov
|
|
|
|
|
There are two SQL Server tables; parent table "Adressen", child table "Details". Details is related with field "adid" to parent table "Adressen". A new Adress Row has multiple DetailsRows.
"adid" is the primary key of "Adressen" and grows 1 by row.
I work with typed Sql Server tables and C#.
simplyfied:
AdressenRow adr_row=new ds1.Adressen.NewAdressenRow();
DetailsRow det_row=new ds1.Details.NewDetialsRow();
//Add the knew Rows
ds1.Adressen.AddAdressenRow(adr_row);
ds1.Details.AddDetailsRow(det_row);
//Update Adressen
xDataAdapter.Update(ds1.Adressen);
//Now I need to have the "adid" of the Inserted Row to set it also in the new DetailsRow but in the DataSet.Adressen Table, adid of the new created AdressenRow is "0".
How I can get this id? Is there the possibility to make a cunning Insert- or Update-Statement?
What's the best way to solve this little problem?
What's the way to solve the problem that DataSource and DataSet is not synchronized?
Thanks
Stefan
|
|
|
|
|
You may have to change your code a bit, but here's the gist:
First, you need a stored procedure like this:
CREATE PROCEDURE [addaddressen]
@param1 varchar(100),
@adid int output
AS
insert into addressen (param1) values (@param1)
select @adid = @@IDENTITY
GO
Notice the @@IDENTITY field. This sql variable contains the ID of the row you just inserted. Then your C# code to retrieve that value would look like this:
SqlConnection SqlCon = new SqlConnection("your_connection_string");
SqlCommand SqlCmd = new SqlCommand("addaddressen", SqlCon);
SqlCmd.CommandType = CommandType.StoredProcedure;
SqlParameter sParam;
sParam = SqlCmd.Parameters.Add(new SqlParameter("@param1",
SqlDbType.VarChar, 50));
sParam.Value = "Test Addressen";
sParam = SqlCmd.Parameters.Add(new SqlParameter("@adid",
SqlDbType.Int));
sParam.Direction = ParameterDirection.Output;
SqlCon.Open();
SqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
string adID = SqlCmd.Parameters["@adid"].Value.ToString();
The string adID now contains your id value of the record you just inserted into addressen. You can now insert into your details table with this ID.
I hope this helps.
-Matt
p.s. You can just do the whole thing in a single stored procedure, like this:
CREATE PROCEDURE [addaddressen]
@param1 varchar(100),
@detailParam1 varchar(100),
@adid int output
AS
insert into addressen (param1) values (@param1)
select @adid = @@IDENTITY
insert into details (adid, detailParam1) values (@adid, @detailParam1)
GO
------------------------------------------
The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
|
|
|
|
|
Thank you for your explainations!
Inbetween I've found now exactly what you wrote to me. But I use now SCOPE_IDENTITY() instead of @@IDENTITY as returnvalue. One thing to add: I use now SetParentRow() of the ChildRows to set the correct id of the ChildRows automaticly when updating the Details Table.
Thanks
Stefan
|
|
|
|
|
I have a toolbar in a form. The text of the buttons on the toolbar are like "&New", "&Edit", "&Search".
But the buttons ButtonClick Event is not fired when I use ALT+"n" or ALT+"e". and so not accessible with the keyboard.
What have I to do that I can access the buttons ButtonClick Event with ALT+"X"?
Thanks
Stefan
|
|
|
|
|
Hello,
I have a really generic question (I hope). I have a Query called "Open Job Orders". In it I have a Table called "Job Order" and in that Table there is a field called "Job Order ID". Here is what I want to do (this is all just for me learning and becoming more familiar with DBs and Queries):
I want to create a string and have the Job Order ID returned into that string.
For instance I did the following
Dim blank As String
Dim stDocName As String
stDocName = "Open Job Orders"
DoCmd.OpenQuery stDocName
blank = [Open Job Orders]![Client]![Client Name]
This will open the Query (just so I can see it) but I want blank to be equal to the first Job Order ID.
How can I do this? I know the code above is wrong. Can someone please explain (if it is not too long) the difference between using a '!' or a '.'? Is there a good book on VBA for Access?
Later on what I want to do is be able to press a command button and have all the Job Order IDs that have no value in them yet be replaced with a default value.
If someone could show me how to get to the tables and fields of a query in VBA I woudl love it.
I hope I was descriptive enough!!
Thanks,
NickOne
|
|
|
|
|
I have a Sql table with a primary key id. This field id is set to identety, growing 1.
I add a row to the related DataTable and update it. Then I need the id (which is set from Sql Server)of the updated row. How can I get this id from C# with ADO.NET, Typed DataSet?
Thanks
Stefan
|
|
|
|
|
To get the last identity value you need to execute a
select @@identity
command. I don't know if ADO.NET will do this automatically for you or if you have to do it yourself.
Dave.
|
|
|
|
|
Thank you for the answer.
Is there no way that I get the wrong id? When another table is updated after my update statement and before I can use "select @@identity"?
|
|
|
|
|
You will be OK as long as you don't have any triggers on the table you are updating that also do inserts. If you have triggers, use Chris' option below.
select @@identity returns the last identity value generated in the current session (which is why triggers with inserts can cause issues), so as long as your session doesn't do any other inserts you are OK.
Dave.
|
|
|
|
|
If you're using SQL Server then use
SELECT IDENT_CURRENT('TableName')
This will return the latest Identity value for the Table called 'TableName'.
cheers,
Chris Maunder
|
|
|
|
|
I am writing a database program using ADO and Visual C++.
Let me explain my problem.
m_pConn->Open(L"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=Inventory.mdb;",
L"", L"", adOpenUnspecified );
...
pRs->Open( _variant_t( bstrQuery ),
vNull,
adOpenDynamic,
adLockOptimistic,
adCmdUnknown );
if( m_pRs->Supports( adDelete ) && m_nNoRows > 1 )
{
m_pRs->Delete( adAffectCurrent );
m_pRs->MoveNext();
if( m_pRs->GetADOEOF() )
m_pRs->MovePrevious();
}
CString strFilter = "vField LIKE 'smth%';
m_pRs->Filter = _variant_t( (_bstr_t)strFilter );
//
After I set the filter and I delete a record, if I try to
move to the previous record (even though the record is not
the first) I get an error which suggests that the row where
I am trying to move is either marked for deletion or has
been deleted. Why? The database supports MovePrevious and
I don't use batch mode. This problem occurs only if I
set a filter. The filter works fine too. It selects only
the records that I want it to select.
// Afterall I realized that even my comment lines have bugs
|
|
|
|