|
I've got a database, it's not set up with cascading delete, and I'd prefer it not be. Instead, I'd like to turn of foreign key checking when I delete all data from all the tables. Is there a way to delete all data without figuring out the correct delete order, by getting SQL Server to ignore the constraints ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I am currently using the following statement to read data from a table, column
my_String = _strdup((char*) ((_bstr_t)(pConnectRead->GetFields()->GetItem("nom_medico")->GetValue())) );
How do i write data to this column?
Please help,
THanks
Ed Rey
|
|
|
|
|
pConnectRead->GetFields()->GetItem("nom_medico")->Value = (LPCTSTR)my_String;
pConnectRead->Update();
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
I am referencing the libraries from msado15.dll and retreiving data from an access database using visual C++. I have already connected succesfully to the DB, and can read data. I use the following command to retreive information from a particular field in the table:
my_String = _strdup((char*) ((_bstr_t)(pConnectRead->GetFields()->GetItem("nom_medico")->GetValue())) );
How do i write a boolean value to a field, once i have established connection to the DB and currently in the row of interest.
Eduardo M. Rey
|
|
|
|
|
if(Condition is true)
pConnectRead->GetFields()->GetItem("nom_medico")->Value = true;
else
pConnectRead->GetFields()->GetItem("nom_medico")->Value = false;
pConnectRead->Update();
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
Thanks for your prompt reply,
I am using the statement you provided:
pConnectRead->GetFields()->GetItem("nom_medico")->Value = false;
within a try-catch loop. but it jumps to the _com_error as soon as it executes this statement. Maybe i am giving the wrong premissions in the statement right before:
pConnectRead->Open(commandString, strConectIt, adOpenStatic, adLockReadOnly, adCmdText);
Thanks again for your help, you were extremely helpful.
Ed
Eduardo M. Rey
|
|
|
|
|
Hi,
I've got a table (whith an index on the CarId field (IdentityIncrement). Now I'd like to write a stored procedure which inserts a new record into this table and returns the CarId of the newly generated record. But I don't know how to do this w/o using a SELECT after the INSERT. Can anyone pls. help?
Thanks in advance.
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
|
|
|
|
|
Create your stored procedure specifying which parameter(s) is/are output parameters like this
CREATE PROCEDURE GetInformation
(
@SomeKey int,
@SomeResult int OUTPUT
)
AS
SELECT @SomeResult = AnswerField
FROM MyTable
WHERE ThePrimaryKey = @SomeKey
GO
Then in your .NET application when you specify the parameters for the stored procedure, make sure you specify which parameter(s) is/are output.
SqlParameter someResult = new SqlParameter("@SomeKey", SqlDbType.Int);
someResult.Direction = ParameterDirection.Output;
When you have run your query, you can then get the value of the output parameter with
int result = (int)someResult.Value;
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!
|
|
|
|
|
After the insert @@identity will contain the new CarId value.
e.g.
CREATE PROCEDURE InsCar
@carType int
AS
BEGIN
insert into car ( CarType, AddDtTm ) values( @carType, GetDate() )
select @@identity as UID
END
GO
[EDIT]
... or, instead of 'select @@identity ...' specify an OUTPUT parameter as Colin mentioned.
[/EDIT]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
hi all,
i want to run the below query on a Ms-Access database
CREATE TABLE products (
product_no integer PRIMARY KEY,
name text,
price numeric DEFAULT 9.99
);
when i run it, its seems that access doesnt like the DEFAULT 9.99 for some reason
however if i run the query in SQL Server it works fine, but i need to run it on
an access database
ne1 any ideas of a way round this ???
thanks
si
|
|
|
|
|
You can use the MS-Access table designer screen to set the column's default value.
If you want to do this programatically then try using the "Default" property in the ADOX Column Properties collection. The SQL syntax in MS-Access does not seem to support this.
Andy
|
|
|
|
|
You need to make Access Table/Queries compatiable with SQL ANSI.
Go to Tools -> Options -> Table/Queries Tab
Now, check the "This database" checkbox under "SQL Server compatiable syntax" option on bottom right side.
Now, you would be able to run this query.
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
Hiya I have a script that I want run when installing my app.
How do I do this??
Thanks.
|
|
|
|
|
|
Colin
You are a star!!
Cheers.
|
|
|
|
|
Hi !
I have a problem. I need to update my database from a xml dataset file but it doesn't work.
1)I fill my dataset with the dataAdapter.
2)I change some data in my datagrid
3)I save my dataset with de writeXml method. ( this part is ok)
4)I fill my dataset with the xml file, readXml (this part is ok)
5) Update ( It doesn't work. my update command is ok and I have no error)
I also tried the getChange method, and saved the result into a dataset saved in xml format. The modified rows(from the dataset created with the getChange method) are insert in the database (not update).
I need help
Thanks
|
|
|
|
|
|
Thr problem with this is that you need to save the XML using a "DiffGram" model. By default, this is not used in the WriteXML and when you Save the XML file and Read it back in, the DataSet thinks there are no changes to be updated. However, one last Quirk, you also need to save the Schema into a different file as well, since you cannot save both the Schema AND the DiffGram into one file.
|
|
|
|
|
Hi
I have a dataset with one table (with 5 columns). Now, I want to extract the DISTINCT values of two columns (OrgID, OrgDesc) and bind it to a combo box.
How can I do that? Please advice. Thanks
PJ
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
Check
http://support.microsoft.com/default.aspx?scid=kb;EN-US;326176
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
thanks .. works great.
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
So you would think a SQL expert like me *ok you didn't have to laugh so loud* would already know this, but I didn't and got burnt.
SmallDateTime rounds seconds to the nearest minute. Fair enough. I didn't know but hey, we have DateTime so lets change the column datatype to that.
Only existing records are not affected. WTF! They act like the column is still a SmallDateTime. Manually adding in a second to the value doesn't help existing records either alas.
So I convert to NVarchar as a temporary hack and use GetDate. Charming, still no seconds. WTF!
So my question is; apart from recreating the whole column and loosing that data, how do I get what was a former SmallDateTime and is now a DateTime to store seconds on existing rows?
I am sure this is one of those Design Features too.
regards,
Paul Watson
Bluegrass
South Africa
Christopher Duncan wrote:
"I always knew that somewhere deep inside that likable, Save the Whales kinda guy there lurked the heart of a troublemaker..."
Crikey! ain't life grand?
|
|
|
|
|
I never knew that either. Thanks for the heads up.
A proposal to getting it working might be to create a new column, copy the data to the new column, then remove the old column and finally change the name of the column. That way, at least you get to keep the data.
"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 think you must be having a blond moment. The datetime type has been used by many people, and it works just fine. Perhaps your particular view of the data is not showing the seconds, but they most certainly are there.
my blog
|
|
|
|
|
Hi,
I tried to create my first stored function in SQL: I wrote this:
CREATE FUNCTION dbo.Function1<br />
(<br />
@Username varchar(50)<br />
)<br />
RETURNS TABLE<br />
AS<br />
RETURN ( SELECT * FROM Users WHERE Username = @Username)
and I wanted to retrieve all data from record in the database about this user.
I am absolute newbie in this, and I have this code to save data to the database:
Dim cmd As New SqlClient.SqlCommand("RegisterUser", vilemConn)<br />
cmd.CommandType = CommandType.StoredProcedure<br />
cmd.Parameters.Add("@Username", txtUsername.Text)<br />
cmd.Parameters.Add("@Password", inputPassword1.Value)
My question is: How can I get data from the database? (I want to save them to the structure.)
And the second question: When I tried this with Run inline function in VS.NET and when I set the value of @Username="blablabla" it got the result, but when I set this value to NULL it said
No rows affected.
No more results.
(0 row(s) returned), despite I have there (for testing purposes only, there will never be any NULL Username ) few NULL values?
|
|
|
|