|
Is there a method to detect if a column has a primary key set, using ADO for C++.
Thanks
|
|
|
|
|
I had created a database(SQL Server) few motnhs before but
unfortunately the database is now missing ,i have only the .mdf file of that database(.ldf is also missing),Can someone tell me how to recover the database from the .mdf file.
Thanx
Pradipta
|
|
|
|
|
You should be able to reattach the .mdf file to sql server. You can do this with Enterprise Manager, or the sp_attach_db system stored proc.
You may get a warning about not having the corresponding .ldf.
Without nipples, breasts would be pointless.
|
|
|
|
|
I tried the following
EXEC sp_attach_db @dbname = N'pubs',
@filename1 = N'c:\mssql7\data\pubs.mdf'
But I am getting following error using the above Stored procedure
--------------------------------------------------------
Server: Msg 5105, Level 16, State 4, Line 1
Device activation error. The physical file name 'c:\mssql7\data\pubs.mdf' may be incorrect.
------------------------------------------------------
But the physical path is correct.I also tried with
sp_attach_single_file_db but same error results.
How can i do the same using Enterprise Manager,It will be highly appreciated if u tell me step by step.
|
|
|
|
|
pradipta wrote:
N'c:\mssql7\data\pubs.mdf'
Are you using SQL Server 7? I can explain how I do it with 2000, but I assume it would be similar process.
Open Enterprise Manager.
Expand the tree until you find your database server instance. Expand that.
Right-click on Databases, select All Tasks -> Attach Database.
Browse [...] for your database file.
As for the error you are receiving, I don't know what the problem might be.
Was the file detached from the original database, or just copied? That may cause problems potentially. But I'm no DBA, so I can't say for sure.
Good luck
Without nipples, breasts would be pointless.
|
|
|
|
|
Thanx a lot,Yeah this is working as per my requirement
Thanx again
With Regards
Pradipta
|
|
|
|
|
Hi all,
How can I create a textual dump of a SQL Server 7 database? I have used MySQL and it provides a feature to take a textual dump, with either structure or structure plus data. So if I want to create the same database elsewhere I can use the DDl statements in the dump to create the same tables.
There are other ways to transfer DB's in SQL server. But I'd like to know if SQL Server supports textual dumps or not. This is mainly for me to transfer a DB in SQL Server 7 in a remote offline system to a SQL server 6 in another system. The export-transfer-import mechanism fails somehow
Thanks
Smitha
It is better to be hated for what you are than to be loved for what you are not.
-- Andre Gide
|
|
|
|
|
Hi,
I want to call an INSERT into my access database via ADO.
To do that operation I use the Execute fonction.
CString query = "INSERT INTO Clinic
VALUE(ClinicID,ClinicName,Address,City,PostalCode,PhoneNumb,FaxNumber,Email,Notes)";
m_pCmdChange->ActiveConnection = m_pConn;
m_pCmdChange->CommandText = (_bstr_t)query;
// CommandText property already set before function was called.
m_pCmdChange->Execute(NULL, NULL, adCmdText);
Into my table, I have a fields named ClinicID that is a Access AutoNumber.
If I execute the preceding code, it work fine except the fact that I have to enter ClinicID that is a autonumber.
My problem is that if I do an execute() I have to add an imput for each fields including ClinicID.
So my question is How can I add a new record into my table without the obligation to enter ClinicID?
thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Sorry if I'm not understanding correctly, but I think you need to try this
CString query = "insert into clinic
( ClinicName
,Address
,City
,PostalCode
,PhoneNumb
,FaxNumber
,Email
,Notes
) values
( 'SomeClinicName'
,'SomeAddress'
,'SomeCity'
,'SomePostalCode'
,'SomePhoneNumb'
,'SomeFaxNumber'
,'SomeEmail'
,'SomeNotes'
)";
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
Well, I understand that you use ADO to insert the new record. The following code is stripped from VB code generated by the data form wizard in VB (with some changes), if you look at the code you'll find that no value was entered for the AutoNumber field, so I assume that if you use the INSERT command without specifying a value for the AutoNumber field it should work too (try it on your own).
There is an AutoNumber field customer_id which doesn't appear in the code, the value of that field is assigned automatically.
' ASSUMING YOU ALREADY HAVE A CONNECTION OBJECT db
'
Dim strSQLQuery As String
strSQLQuery = "SELECT Customer.* FROM Customer"
Set tblCustomer = New ADODB.Recordset
tblCustomer.Open strSQLQuery, db, adOpenStatic, adLockOptimistic
tblCustomer.AddNew ' HERE YOU ADD A NEW RECORD
tblCustomer!customer_name = "John"
tblCustomer!district_code = 55
tblCustomer!industry_code = 17
tblCustomer!entity_type_code = 12
tblCustomer!branch_code = 5
f_tblCustomer.Update
(a.k.a. Wal2k) www.wal2k.com
|
|
|
|
|
Here's my situation. I know nothing about database programming. I know lots about C++ and MFC and I use Visual C++ 6.0 but also have VS.NET 7.0. Someone has given me a machine with SQL Server and database on it. The database is not very big, maybe 1000 records. I want to get the database off the machine and I want to write an MFC application that will access the data and display it. I want to ship the application and I don't want people to have to have SQL or install anything extra to use the application. I'm sort of hoping that I can convert the database to some sort of file (maybe Access) and query it from MFC. The application would ship with the data and all reading and querying from the file would be local to the machine that the application is installed on.
How would people get started with this and does anyone have any ideas on how to proceed.
Thanks,
Brent
Brent Corkum
|
|
|
|
|
with such few records you can as well export the data in some sort of flat-file (e.g CSV). Read the file at program start-up into memory as a balanced tree or double-linked list or into a list-control.
Whenever you use some sort of database, you got to deal with a lot of prerequisites (is the proper version of MDAC / ODBC etc. installed?), so this aproach should be easier.
dirk
|
|
|
|
|
In SQL Server is it possible to have a trigger that will throw an event which could be caught by C# program running in the back ground?
Is this even possible? If it is, have u any links to help/examples?
|
|
|
|
|
I'm querying an MS Access database table from an ASP page using ADO. My query returns a number of fields per row. The last few fields are null when I access them from the ASP page, even though in the database they are not.
I'm guessing that this is because:
1) the data in all the fields combined exceeds the row's buffer size.
or
2)the number of fields exceeds the maximum # allowed(unlikely, but possible)
Is one of these correct, and if so, is there any way to either (1) increase buffer size or (2) increase max # of fields?
Note: I have tried re-ordering the fields and always the last few fields are null but no others.
|
|
|
|
|
How can I check if the columns in the table has a primary key in ADO for vc++.
Thanks
|
|
|
|
|
I am trying to connect to MSDE using vb.net for asp.net
constr="Server=AJAY-KALEKAR\VSdotNet;databaes=mydatabase;user=admin;password=admin"
It is not connecting gives error
AJAY-KALEKAR\ASPNET not valid user
I tried giving access to ASPNET user account the access to the database.
Do i have to log into my machine with ASPNET user account. Currently i login as administrator. Please let me know.
Thanks,
Ajay
|
|
|
|
|
MSDE supports only windows authentication, and does not support SQL Server authentication (user/password you passes in the connection string). As your ASP.NET page runs inside aspnet_wp.exe process, which runs under YOUR_DOMAIN\ASPNET account, you must grant it access to your database (either from osql.exe tool or from the EM).
Also, you misspelled the "database" key ("databaes").
HTH
Alexandre Kojevnikov
MCP (SQL2K, Win/C#)
Leuven, Belgium
|
|
|
|
|
Hi,
I'm new to ADO and I would like to know how I can add a new record into my database.
Suppose that I have a structure that correspond to my database table named Clinic:
struct Clinic
{
CString name;
CString address;
CString PhoneNumber;
}
My connection and my recordset instance are already created and my connection to the database is opened.
What can I do up to now?
I have already tried:
m_pRS->GetFields()->GetItem("ClinicName")->PutValue(Clinic.name);
m_pRS->GetFields()->GetItem("Address")->PutValue(Clinic.address);
m_pRS->GetFields()->GetItem("PhoneNumber")->PutValue(Clinic.PhoneNumber);
but it doesn't work.
help needed!!;)
Regards
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Try m_pRS->AddNew();
Alexandre Kojevnikov
MCP (SQL2K, Win/C#)
Leuven, Belgium
|
|
|
|
|
Hi, I have some problem with ADO.
I use Access and MFC.
My problem is that I get an error when I try to get data from an empty field in a record. In my table I have FirstName, LastName and PhoneNumber. It's not necessary to put a value into PhoneNumber. So when I try to get the data, I have "invalide data type" error. All my data are CString type.
So I supposed that ADO cannot change something "empty" to CString...
Any ideas?
thanks
Everything's beautiful if you look at it long enough...
Everything's beautiful if you look at it long enough...
|
|
|
|
|
I'm looking at storing text in a MS Access database, but the amount of text may very easily exceed the 64k restriction on the "memo" data type. What would be the best way of implementing this? Yes, I know I could store the data in a text file and place a filename in the database, but I'd rather keep it all in the database if possible.
Any help would be greatly appreciated
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
|
|
|
|
|
Hi,,
try the Ole object type and deal with text as binary..
use AppendChunk function (ADO,DAO) to add text to field.
|
|
|
|
|
I have table (in sql server database) which contains two fields ,Name(varchar) and Date_of_Birth(Datetime)
I want to fetch those records whose birth day is in this week (incuding today(system date)).
Please help me with the query
|
|
|
|
|
SELECT t.Name <br />
FROM MyTable AS t <br />
WHERE DATEPART(week,t.Date_of_Birth)=DATEPART(week,GETDATE())
Alexandre Kojevnikov
MCP (SQL2K, Win/C#)
Leuven, Belgium
|
|
|
|
|
thats nice ,but i want only those date of birth which is between today and 7 days after today(not before).
for example today date is 4/1/2003
i want to fetch those date of birth which is today and 7 days from today i.e
the records should be like below()
4/1/2003
4/2/2003
4/3/2003
4/4/2003
4/5/2003
.........
|
|
|
|