|
I am using SQL Server 2008 R2.
|
|
|
|
|
The command to create a database is documented here[^], examples are at the bottom of the page.
Bastard Programmer from Hell
|
|
|
|
|
Hi,
Can we create the mdf file by taking the backup of one existing database ?
Regrds,
Lalit
|
|
|
|
|
Yes. Backup the existing database, and restore [^] it. Keep in mind that this procedure will convert "older" database versions (backups from 2005) to the format of your server (2008R2).
Bastard Programmer from Hell
|
|
|
|
|
Hi, everyone, I'm using sqlite 3.6.22 in an ARM-linux based application, and I was annoyed a lot by a memory-leak problem.
this is the problem:
sqlite3_free_table(char **result) doesn't exactly release the memory allocated by sqlite3_get_table function.
To verify it I made it called dirrectly after sqlite3_get_table() function, but I can still access the azResult parameter.
bellow is part of my code:
sqlite3 *db;
char *sqlcmd;
int nrow ;
int ncolumn ;
char **azResult;
char *zErr;
int rc;
rc = sqlite3_open("/usr/YY_AEACard.db", &db);
if (rc) {
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return -1 ;
}
sqlcmd = sqlite3_mprintf("select CardID,CardType,BgnDate,EndDate,ValidTimes,CardRight,CardFlag, EnabledPorts,LastAccessPort,CardPsw from tb_CardInfo where CardID=%d and EnabledPorts = %d\n",card->CardID, nPort );
sqlite3_get_table( db, sqlcmd, &azResult, &nrow, &ncolumn, &zErr );
sqlite3_free( sqlcmd );
///////////////////////////////////////////////////////////
sqlite3_free_table(azResult);
///////////////////////////////////////////////////////////
// it still works when i do this here.
if (rc != SQLITE_OK) {
if (zErr != NULL) {
fprintf(stderr, "SQL error: %s\n", zErr);
sqlite3_free(zErr);
}
}
if(nrow <= 0)
{
printf("No data from db!\n");
return -1;
}
if(ncolumn < 9)
{
printf("Columns are not enough for card table!\n");
return -1;
}
bzero(card, sizeof(card));
card->CardID = atoi(azResult[ncolumn+0]);
card->CardType = atoi(azResult[ncolumn+1]);
strcpy(card->BgnDate, azResult[ncolumn+2]);
strcpy(card->EndDate, azResult[ncolumn+3]);
card->ValidTimes = atoi(azResult[ncolumn+4]);
card->CardRight = atoi(azResult[ncolumn+5]);
card->CardFlag = atoi(azResult[ncolumn+6]);
card->EnabledPorts = atoi(azResult[ncolumn+7]);
card->LastAccessPort = atoi(azResult[ncolumn+8]);
strcpy(card->CardPsw, azResult[ncolumn+9]);
sqlite3_free_table(azResult);
//this is a test for the memory leak
printf("%s\n", azResult[4]);
//funny enough, it still works here.
sqlite3_close(db);
return 0;
please help me, thank you.
|
|
|
|
|
There is no guarantee that the memory pointed to is overwritten when it is released. In my experience, only a very few debugging memory managers bother to overwrite released memory blocks. So what you observe is not evidence of a memory leak. Your system may have some functions to query the memory manager for such things as the total allocated memory size.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thank you Peter, we usually meet a "Segment fault" when we access to the memory released, and further more, the memory of my application keeps expanding with the size of the data loaded from database, never the end.
|
|
|
|
|
My guess is that sqlite is keeping various things in memory as long as you have the database open. Is all the memory freed when you close the database(s)? Or, at least, does the memory usage stop increasing when you close and reopen the database?
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Yes, Peter, SQL Server manages its memory this way, I don't exactly know how sqlite does with it. but what ever, it shouldn't expand to crash the operation system.
|
|
|
|
|
by the way, i closed the database after each opration.
|
|
|
|
|
I'm trying to debug whether or not a SSRS app is leaving open sql connections. I wrote a test app that uses a custom SSRS reporting object (written in VB.net) that calls reports in a loop. Each time the reporting object is destroyed and recreated.
The server is 2008 R2 and the SQL server is 2008 R2. I have Performance Monitor open on the server with the following counters added in:
ReportServer:Service - Active Connections
SQLServer:General Statistics - User Connections
SSRS.ActiveConnections is displaying 97 current connections.
SQL.UserConnections is displaying 38 current connections.
If I open Management Studio and use the Activity Monitor, selecting all databases - there are exactly 38 connections. If I run sp_who2 and remove the lines that are for the master DB and sa account, there are again 38 connections (prior 64)
I'm very confused on the different #s being reported in the counters. Can anyone shed light into this? Is the ReportServer:Service - Active Connections actual DB connections or connections to the service? Should the SQL.UserConnections include SSRS report connections?
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
How to use workflow foundation (sequential flow)in asp.net(visual studio 2008) web application. If anyone know then send me the reply ASAP.
|
|
|
|
|
Why have you posted this in the Database forum?
|
|
|
|
|
Is that possible to include word file in SSRS report (version 2008) without using code base or third party tool.
|
|
|
|
|
|
Hi all..i have a created a wcf data service using entity data model on oracle db.
I have to customized my data for the data services a lot..and have already created LNQ for the same. Is it possible to use this Linq query for displaying the data in to data services itself?
thanks
Vandana
|
|
|
|
|
vkap wrote: displaying the data in to data services
This is contradictory, a service does not display, that is a UI job, not a service job.
You can use the WcFTestClient to log on to the service and execute the methods you have exposed to get the results!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi everyone! I need to get a list of users connected to a database. I want to implement a fuctionality in my application that allows users connected to the database to communicate. For instance one administrator in his office can request or send information to another in an office through the network.
A user executing 'select * from master..sysprocesses' does not show all connected users but only the one executing the command. How do I get users to view list of connected users so that they select the one they need to communicate with? I'm using Sql Server 2005. Thanks in advance.
|
|
|
|
|
I'm not sure, but I believe that you need to be a sysadmin member to view which other users are connected. Since you (probably) will not promote every user to an admin, I'd suggest rolling your own. It's quite easy to create a table with a username and a datetime of login. Insert the users' name when he/she logs in, delete it if they logout or are inactive for a specified period of time.
Bastard Programmer from Hell
|
|
|
|
|
You can look at these commands, but I beleive you need elevated permissions to see other people on the server.
Maybe you could write a web service that connects to the database with Admin privs and returns the list of users for each request. This would allow you current user configuration no to change, just some additional functionality would be published.
Just a thought.
Remeber to vote.
|
|
|
|
|
Thanks David and Eddy. I got the solution. It is done by executing 'GRANT VIEW SERVER STATE TO [LOGIN]' at the server scope. It works now.
|
|
|
|
|
Hi,
I want to secure a database in SQL Server 2008. Here is the situation description:
I am using both 'windows' and 'sa' authentication. When I create a database (logged as 'windows' authenticated) I can see and change it (create tables, stored procedures) from logged as 'sa' authentication or vice versa. So, there is no difference whether I create it logged as 'windows' or 'sa'. But, what I need is to secure a particular database i.e. even if I am logged as 'windows' I want the particular database to be accessed only by providing a username and password.
Do you have any idea how to resolve this?
modified 25-Jun-12 6:29am.
|
|
|
|
|
Can't be done; the Administrator of the local computer is considered to be the owner of his/her data.
Alternatively, you might consider another database, or hosting your server on a different machine than the users'.
Bastard Programmer from Hell
|
|
|
|
|
Can you give any details (how to consider another database)?
|
|
|
|
|
Kujtim Hyseni wrote: Can you give any details (how to consider another database)?
A comparison on databases can be found here[^]. Both MySQL and Oracle provide free alternatives that may fit your requirements.
Bastard Programmer from Hell
|
|
|
|