|
smita_roy wrote:
How can i hide a database to be listed in sql enterprise manager
=> No u cannot hide ur DB in SQL Enterprise Manager, I think. Because this GUI used to manage Databases
smita_roy wrote:
how can i prevent data from being deleted in a table through enterprise manager
=> u need to ensure that there's no one knows ur DB password except u
<< >>
|
|
|
|
|
(1) How can i hide a database to be listed in sql enterprise manager ?
Just Detach the Database in the Enterprise Manager.
(2) How can i prevent data from being deleted in a table through enterprise manager ?
Remove the permission from the user
REVOKE priv_type [(column_list)] [, priv_type [(column_list)]] ...
ON [object_type] {tbl_name | * | *.* | db_name.*}
FROM user [, user] ...
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...
|
|
|
|
|
I have a simple insertinto statement with the correct syntax:
INSERT INTO BookingBook ('Date') Values ('01/01/2006');
Why is it throwing up the error that there is no such field as date when there most definitely is... Does the fact that it is a reserved word have anything to do with it...
Thanks.
°[Halo]°
Project Basilisk
|
|
|
|
|
INSERT INTO BookingBook ([Date]) Values ('01/01/2006');
The apostrophes indicate a string literal. Use square brackets or quotes.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
°[Halo]° wrote:
INSERT INTO BookingBook ('Date') Values ('01/01/2006');
the field name is not qouted by brackets, the correct one should be
INSERT INTO BookingBook (Date) Values ('01/01/2006')
u can refer in SQL book online
<< >>
|
|
|
|
|
You could convert the string date on the fly ( if your usinf TSQL )
<br />
INSERT INTO BookingBook ('Date') <br />
Values ((Convert( datetime, '01/01/2005', 103 ))<br />
103 is DD/MM/YYYY
I prefer stating the exact date to SQL as it stops date problems with mixing up DD and MM.
|
|
|
|
|
INSERT INTO BookingBook ([Date])
Values ((Convert( datetime, '01/01/2005', 103 ))
|
|
|
|
|
Using sq brackets did not solve this. This provided me also with the error "INSERT INTO statement contains an unknown field 'Date'" or something to that effect. In the end I just changed the field name... I believe that access is reading "Date" as an identifier rather than a field name where it expects a field name...?
°[Halo]°
Project Basilisk
|
|
|
|
|
Quite possibly. If this is on MS SQL, try using brackets [] around the field.
|
|
|
|
|
Doh.. replies didnt show up at first. Ignore redundant post.
|
|
|
|
|
Hi !
I want to search the field of "telephone":
table:MyTable ,
id_name[int],name[nvarchar],family[nvarchar],telephone[decimal]. id_name is a primary key .
when I want to search a telephone , for example:
telephone=3339964
I write in c#:
string mysearch;
mysearch="SELECT * From MyTable WHERE telephone=3339964"; Now , If the telephone is NULL (one don't enter his telephone) and I want to search this name and family,How can I write this SQL ?
mostafa hosseiny b.
|
|
|
|
|
So, you want a query that will search by telephone. If telephone is null you want to seach by name and family instead.
This is the query you want:
SELECT *
FROM MyTable
WHERE (telephone=@telephone AND @telephone IS NOT NULL)
OR ((family = @family AND name = @name) AND @telephone IS NULL)
And the C# code to go with it:
string mySearch = "SELECT * "+
"FROM MyTable "+
"WHERE (telephone=@telephone AND @telephone IS NOT NULL) "+
"OR ((family = @family AND name = @name) AND @telephone IS NULL)";
SqlCommand cmd = SqlCommand(mySearch, myConnection);
cmd.Parameters.Add("@telephone", telephoneNumber);
cmd.Parameters.Add("@name", name);
cmd.Parameters.Add("@family", family);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
}
From the code above telephoneNumber needs to be an object as it needs to be able to supply a System.DBNull.Value in place of the number. You could set this up like this:
object telephoneNumber;
if (telephoneNumberTextBox.Text == "")
telephoneNumber = System.DBNull.Value;
else
telephoneNumber = telephoneNumberTextBox.Text;
By the way, I'm not sure storing a telephone number as a decimal is the best approach. Certainly I've always stored them as strings and I've never seen them stored in any numeric format. How do you deal with phone number that start with a zero, or international numbers that are stored with a country independent prefix of +, or special service phone numbers that include the * or #.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Thanks in advance !!;)
mostafa hosseiny b.
|
|
|
|
|
manije wrote:
Thanks in advance
Are you a time traveller??
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
yes , and I do'nt Know , How do you understand .
Ofcourse , your guide , was very good and my means , was the same I want .
'@myVar IS NULL' .
Thanks again , but instead of using
'@myVar' , I use field name directly and I'd no problem but Really I do'nt know,How can Use with
'@'=variable in sql in c# .
Thanks,again .
mostafa hosseiny b.
|
|
|
|
|
I'll repeat my example with greater annotation:
string mySearch = "SELECT * "+"FROM MyTable "+
"WHERE (telephone=@telephone AND @telephone IS NOT NULL) "+
"OR ((family = @family AND name = @name) AND @telephone IS NULL)";
SqlCommand cmd = SqlCommand(mySearch, myConnection);
cmd.Parameters.Add("@telephone", telephoneNumber);
cmd.Parameters.Add("@name", name);
cmd.Parameters.Add("@family", family);
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
}
manije wrote:
but instead of using @myVar, I use field name directly and I'd no problem
These are two separate things. I cannot see how that would work without seeing your code. I suspect that there is some confusion with terminology here.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
My Means is :
I do'nt know About variable in sql (like this :@telephone), or atleast I do'nt know,that what's
@telephone
in the code you wrote me(in c#).only I know ,it's a variable in SQL , but , How To Use!!!
thanks for patient .
mostafa hosseiny b.
|
|
|
|
|
To use a variable in SQL you must declare it first, then you can use it.
e.g.
-- First declare the variable
DECLARE @myIntegerVariable int
-- Now it can be used.
SET @myIntegerVariable = 12;
-- To get the result of a column in a SELECT statement that returns just one row.
SELECT @myIntegerVariable = COUNT(*) FROM MyTable;
-- To use as a filter in a SELECT statement
SELECT * FROM MyTable WHERE MyColumn = @myIntergerVariable
If the variable is arriving as a parameter into a stored procedure, then the definition of the procedure declared the varibale implicitly. e.g.
CREATE PROCEDURE dbo.MyProc
@myFirstParameter int,
@mySecondParameter varchar(20)
AS
-- Do the processing of the Stored Procedure
GO
In C# you can supply varibles as parameters to any SQL in the SqlCommand.CommandText . This was the version that I showed you already in the example in my previous post.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
OK! And I Understand .
thanks again !
mostafa hosseiny b.
|
|
|
|
|
I have an typed collection wich is bounded to datagrid control like this:
dataGrid1.DataSource = collection;
How to disable 'new row' in DataGrid ?
object oriented
uml oriented
iconix oriented
sql oriented
truespace oriented
---
solitare oriented
|
|
|
|
|
airbus380 wrote:
How to disable 'new row' in DataGrid ?
Sorry if I missunderstood.
just do nothing in OnItemCreated event
<< >>
|
|
|
|
|
Check if your collection has a property called
AllowNew. Just set it to false.
|
|
|
|
|
I'm using MS Hierarchical FlexGrid to display hierarchical data from a database in a grid. As of now, I can't find out how to do that. I'm using Microsoft Visual C++ .NET 2003. I want to display data from two tables. One table has primary information, and the second table has multiple records for each record in the primary table. I'd like to display just the primary information and just let the user highlight a record to see what records in the second table belong to it. If anybody knows how to use the MSHFlexGrid (mshflxgrd.ocx... as opposed to the non-hierarchical one msflxgrd.ocx) and could offer any help, that'd be appreciated. Or if anybody knows how to solve this problem without mshflexgrid, that'd be great as well.
|
|
|
|
|
Lets see this can help
first filling records in grid
1.loop through the recordset
2.add a new blank row to the grid
3.keep a counter
4.use set_textmatrix(counter,colno) to fill records
now on click event of the datagird capture the row number that was clicked
use get_textmatrix to get the primary key value and show he data from the second table
|
|
|
|
|
Hi
I have a table as
mineralID year value
1 91 1000
2 91 2000
3 91 3000
1 92 500
2 92 300
3 92 8000
1 93 2000
2 93 1000
3 93 1100
I want to a table as
mineralID totalValue
1 3500
2 3300
3 12100
What should i do plz?
|
|
|
|