|
ived use the sqlconnection class to coonect to sql server 2000 and use its sqlcommand to write query and datareader to retrive data the prob is that when ever i have to refer a databse table i have to make a new coonection useing coonection string...and than acce the table.
is there any class and method so dat just need 1 connection too the datbase and refer too any table...
do guide me
thanx
|
|
|
|
|
Must wrote:
ived use the sqlconnection class to coonect to sql server 2000 and use its sqlcommand
Can you tell me what is your code? Then maybe I can help you.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
You can declare an object first, so you have to call an object to use it.
for example in C# :
private SqlConnection conn;
public Connections()
{
conn = new SqlConnection("server=(local);database=pubs;Trusted_Connection=yes");
}
when you need a connection, you just open a connection with : conn.Open();
Hope help..
|
|
|
|
|
If the connection string is (exactly) the same, then you'll benefit from connection pooling.
Other than that, I'm not sure what you're after.
Cheers,
Simon
"Every good work of software starts by scratching a developer's personal itch.", Eric S. Raymond
|
|
|
|
|
Hi,
In a nutshell: If i kill an MFC+DAO based server application while it is updating records using ctrl-c, the application exits and the database shows 0 records even though, 2 seconds ago, DaoRecordset::RecordCount() was returning 1000.
It listens for messages on a socket and updates a RecordSet in table "CallLog".
During update, I can see that RecordSet_for_CallLog.GetRecordCount() returns 10, 11 & 12 etc. records as messages are received over the socket, parsed and updated in the dbase.
The problem occurs when I close the application midway while it is updating the Recordset. I can see that previous calls to GetRecordCount() were returning 10, 11, 12 etc. but when I open the database file in MS Access, there are no records in the table CallLog.
If I open the file in Notepad, I can see the Record data in a jumbled form somewhere. So I guess, for some reason, MS Access garbles up the file while exiting, can someone tell me why? I need to handle this to avoid accidental failure.
The main class is not derived from CWinApp. I call the constructor and methods directly in _tmain(). I made the application using the "Win32 Console Application" option in the New project Wizard and later checked the option for MFC support.
I have mainly worked in the Win32 API and on Linux, using a comiler from the commandline, so this MFC+DAO mumbo jumbo is pretty confusing. Even Charles Petzold says so
|
|
|
|
|
I guess that the database transaction gets rolled back when the application is aborted.
|
|
|
|
|
thanx for the reply, but if ut got rolled back, i would not see any data, if i open the file in notepad or ultra-edit, i can see my data, login_names and IP's etc. so i guess the prob is not there. thanx anyway!
|
|
|
|
|
I don't believe your assumption is correct. Access doesn't necessarily overwrite deleted data in the file, it may just be marked as available space. Then the table will be empty when viewed in Access, but parts of the data may be contained in the .mdb file.
|
|
|
|
|
fine, that's ok but before i close it with the cross on the console or thru ctrl-c i see CDaoRecordSet::GetRecordCount() returns 11, 12, 13.
When i open the mdb file in access, the table shows zero records. i am not using daoworkspace, is that the problem?
|
|
|
|
|
Dear codeproject users,
I need to build a system for put in communication information providers and users.
I mean that I should have a database with some columns like, Name, address, phone#, email, stocklist.
Every provider of informations will have it's account, and will be able to update his information, like when they have a change in stock list, when they change the phone number (frequently since they move a lot), etc.
The users need to search in the database for the people that match their criteria, like, they live in the same address, the have stock list of "Java programming books". etc.
I hope you got the idea.
Now I tought I need 1 database, and 2 applications.
The provider application will let every provider log in it's account with a USERID and a PASSWORD, and afther that modify trough the APP his row in the database, update columns etc.
The user application will let every user search in the database with some criteria.
Ok.
Now I want to know.
How I make a database of this kind, where a provider can logon and modify ONLY one row in the database.
How I build the application, I am supposed to use Visual C++ (with .NET if necessary).
I think you understand that I ask this because I'm a beginner!
Thank you.
"Nelle cose del mondo non e' il sapere ma il volere che puo'."
|
|
|
|
|
please refer to CodeProject -> database -> Ado.
you may find articles for beginners .
you also need to know some transact sql programming.
don't giveup.
It's will take a while.
Aizik Yair
Software Engineer
|
|
|
|
|
I have a situation which I am trying to solve just by creating SQL's without programming because of some installation requirements. I did not have any luck with it. Was wondering whether anyone knows of a solution :
Here is the situation-
DB2 Table 1:
------------
FirstName LastName DateOfBirth History Date
--------- -------- ----------- ------- ----
Joe Smith 01/01/95 05/25/1997
Joe Smith 01/01/95 11/01/1997
Bob Smith 05/07/55 10/01/1998
Sherri Gaston 11/11/73 11/15/1999
Sherri Gaston 11/11/73 12/20/1999
Sherri Gaston 11/11/73 05/05/2000
Primary Key in the above table is FirstName, LastName, DateOfBirth.
From the above table I am trying to create a "daily" level table which will have a record for every primary key starting from the history record date to the next history record date.
So for example the result for "Joe Smith" will be
Joe Smith 01/01/95 05/25/1997
Joe Smith 05/26/1997
Joe Smith 05/26/1997
Joe Smith 05/26/1997
Joe Smith 05/26/1997
.........until 11/01/1997 (his last record's history begin date).
I don't mind building intermediate temporary tables. Can anyone help or thing of something?
Thank you
M
|
|
|
|
|
I am working with C++ and MSAccess trough ODBC and I have a ligistics nightmare when it comes to releasing new versions of my databases. Right now, If I make a change to my database structure I have to write a little patch program that will add, remove, or edit columns or tables in the database and these things are hardcoded and can only work for specific versions.
I was wondering if anyone knows of any utility programs that will let me make the changes over multiple versions. Basically, if the user has version 1.0 and wants to upgrade to 3.0 the utility will then change the existing database appropriatly. Or a user wants to go from 2.0 to 3.0 and so forth.
So a utility that will let me store what needs to changed in the database from version to version, and make these changes on upgrade. That way, the users don't lose any data and the program won't crash from trying to access a column that was not in the older versions.
Thanks in advance,
***********************
Tony Fontenot
Recreational Solutions
tony@recsolutions.com
***********************
|
|
|
|
|
Don't know if this helps but thier is a undocumented access command switch /decomplie.
It will upgrade or change the database to your version of visual basic. Needless to say use with extreme caution.
MSACCESS.EXE /decompile c:\somename.mdb
For a utily to handle different versions You might want to try MS Project.
|
|
|
|
|
I don't know of any utility that does this, but the problem is the same with any database tool you happen to be using.
What I have done in the past is to write a conversion utility to convert from V1 to V1.5, V1.5 to V2, etc. Instead of updating the database they are using you might consider moving their data into a new database instead. What I do is if they are installing Version 3.0 over version 1.0, I do 2 conversions. First I move their data from 1.0 to 2.0. And then I move the converted 2.0 database to 3.0.
Pain in the but, but I only have to deal with the 2 most current versions at any given time.
|
|
|
|
|
Is it possible, within a stored procedure, to get server IP?
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
Its ugly (I'd go so far as to say "pug fugly"), and you'd have to parse the results...
<br />
use master<br />
go<br />
<br />
exec xp_cmdshell 'ipconfig'<br />
Andy Gaskell, MCSD MCDBA
|
|
|
|
|
.. or you could write an extended stored procedure ??
|
|
|
|
|
Hi, I'm having big trouble accessing recorset elements. I'm using ODBC(MSSQL) with CDatabase and CRecordset objects, I can perform SQL executes, and even seem to open recordsets without bother but come into trouble when I try to access a recordset field.
I have CDatabase* called pDB. I have used recordsets previously but only used to check the number of rows returned (and thus not attempted to read any fields).
As far as I can tell there shouldn't be a problem here (I've copied most of this section straight from MSDN). The SQL statement returns a 1 row of 1 field recordset and the datatype of that element is varchar.
Hi, I've written the following code
char strSQL[2048];
try {
sprintf(strSQL,"SELECT DataValue FROM dbo.SSEData WHERE (DataName = N'LOGON')");
printf("%s\n\n\n", strSQL);
CRecordset rs(pDB);
printf("Just setup Filter\n");
if ( rs.Open( CRecordset::snapshot, strSQL) )
printf("Just opened recordset\n");
else
printf("Failed to open recordset\n");
if (rs.GetRecordCount() == (long)0){
printf("No records found");
} else {
if ( rs.IsEOF() )
printf("The recordset was EOF");
if ( rs.IsBOF() )
printf("The recordset was BOF");
printf("Field Count : %d \n", rs.GetODBCFieldCount() );
rs.AssertValid();
printf("Recordset was greater than nothing\n");
CString CStartupMessage;
CDBVariant CVariantField;
printf("In between the first and last string\n");
// rs.GetFieldValue( (short)0, CVariantField );
rs.GetFieldValue( short(0), CStartupMessage);
printf("Got the field value\n");
}
rs.Close();
} catch(CDBException *e){
printf("Caught a DB exception\n");
e->Delete();
} catch(CMemoryException *m){
printf("Caught a memory error\n");
TCHAR ErrorMessage[256];
m->GetErrorMessage( ErrorMessage, 255);
printf("Finished capturing error %s\n", ErrorMessage);
}
The Output from this code is:
<database opened="" successfully="" +="" few="" operations="">
....
Just setup Filter
Just opened recordset
Field Count : 1
Recordset was greater than nothing
In between the first and last string
Caught a memory error
<end>
Can anybody help me ????
Thanks, Damian Del Campo (damian_jose@yahoo.com)
|
|
|
|
|
|
Can SQL Server 2000 and Oracle 9i live on the same machine?
|
|
|
|
|
Yes...;)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Yes, can do...;)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
|
If I have a database on one hosting companies servers and it's huge like 300mb and I was interested in switching providers how would I transfer my database from one to the other...?
is there a command to convert binary database data into a text file dump of SQL INSERTS...?
If so...would I then just ask the new hosting company to convert the text file into binary again...?
Thanx again!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|