|
Set a password that other people can't open my mdf file
|
|
|
|
|
I guess, this link [^]can help you
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
You cannot set password on the SQL Server mdf file as you do with an Access mdb file. Use SQL Server Authentication to restrict what users can see.
|
|
|
|
|
I setup a simple sample program to expose a problem I have with the EntityFramework.
A simple table contains 3 fields
contactguid UNIQUEIDENTIFIER Default: NEWID()
surname VARCHAR(255)
forename VARCHAR(255)
I have created an EntityFramework model for it and wrote this code
policy = dbContext.CreateObject<tblContact>();
policyHolder.Surname = "Blog";
policyHolder.Forename = "Joe";
dbContext.SaveChanges();
The issue is that whatever I do the query set to the database will look like this:
exec sp_executesql N'insert [dbo].[tblContact]([ContactGUID], [Surname], [Forename])
values ('00000000-0000-0000-0000-000000000000', 'Blog', 'Joe')
I was not expecting the ContactGUID to be set with zeros but the default NEWID() to be returned to the client.
This is not happening.
I have tried to change about every property of the contactguid field (particularly StoreGeneratedPattern) but nothing seems to have any action.
Did someone hit this problem?
modified on Friday, July 22, 2011 4:39 AM
|
|
|
|
|
Replying to my own message.
My good colleague Adam found an excellent blog post about this exact problem.
The solution to this problem is simple is to edit the your model edmx file.
In the property element which originaly was:
<Property Name="ContactGUID" Type="uniqueidentifier">
I need to add the StoreGeneratedPattern="Identity" attribute.
<Property Name="SectionGUID" Type="uniqueidentifier" Nullable="false" StoreGeneratedPattern="Identity">
The generated SQL then seems very good, as not only the default value are not overwritten but they are returned to the client in a single query.
declare @generated_keys table(ContactGUID uniqueidentifier)
insert [dbo].[dtblContact](surname, forname)
output inserted.ContactGUID into @generated_keys
values ('Blog', 'Joe')
select t.ContactGUID
from @generated_keys as g
join [dbo].dtblContact as t on g.ContactGUID = t.ContactGUID
where @@ROWCOUNT > 0
For
more details visit: http://leedumond.com/blog/using-a-guid-as-an-entitykey-in-entity-framework-4/[^]
modified on Friday, July 22, 2011 4:39 AM
|
|
|
|
|
Hi,
What I have is table Student and Poke
Student
------------------------------------
Student_Id(PK) | Name
------------------------------------
1 Alex
2 Bob
3 Caveman
Poke
----------------------------------------------------------
Poke_Id(PK) | Poke_Giver_Id(FK) | Poke_Receiver_Id(FK)
----------------------------------------------------------
1 1 2
2 1 2
3 2 1
What I'm trying to get is something like this.
----------------------------------------------------
Poke_Id | Poke_Giver_Name | Poke_Receiver_Name
----------------------------------------------------
1 Alex Bob
2 Alex Bob
3 Bob Alex
Please help.
|
|
|
|
|
With simple inner join here is query which you need:
select p.poke_id, s.[Name] as Poke_Giver_Name,s2.[Name] as Poke_Receiver_Name
from students s
inner join Poke p on p.Poke_Giver_Id = s.Student_Id
inner join students s2 on s2.Student_Id = p.Poke_Receiver_Id
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Exactly what I need. Thanks
|
|
|
|
|
You are welcome.
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Declare @Student table(StudentID int identity,Name varchar(20))
Declare @Poke table(Poke_Id int identity,Poke_Giver_Id int,Poke_Receiver_Id int)
insert into @Student values('Alex'),('Bob'),('Caveman')
insert into @Poke values(1,2),(1,2),(2,1)
Select x.Poke_Id,x.Poke_Giver_Name,Poke_Receiver_Name = s.Name
from(
Select p.Poke_Id,s.Name Poke_Giver_Name ,p.Poke_Receiver_Id
from @Poke p
join @Student s
on p.Poke_Giver_Id = s.StudentID
)x
join @Student s on s.StudentID =x.Poke_Receiver_Id
Niladri Biswas
|
|
|
|
|
-- Modified Monday, August 8, 2011 1:13 AM
modified 2-Aug-13 8:17am.
|
|
|
|
|
Did you actually consider typing that into a search engine before you asked the question - it really does save time doing just a little research before posing a question in the forums.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
velmahesh wrote: If this post is useful,
Nobody asked you for that help!
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
Well, that seems to be his signature.
|
|
|
|
|
It looks like part of question!
That CP member must format his/her signature
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
velmahesh wrote: Please,Dont Forget to click Accept Answer and Click vote.. Earn
Points.
That's an automatic 1.
|
|
|
|
|
Hi All,
I have 3 reports that run fine individually showing headers and data. The queries use no parameters just a calculated date within the query.
I'm trying to place all 3 reports (They are related but do not require each other)into one document as this is the user requirement and thought that this would be easy using the sub-report feature.
I've taken 1 report and tried dragging and dropping one of the other reports onto the report layout designer where it appears as a grey box with the name of the report in the centre. I've checked the visibility is set to visible and data output is set to Yes (I'm guessing here).
When I preview the report the first report shows fine, i.e. the one I started with, but subsequent reports do not show at all - header or data.
Googling the issue makes me think I'm doing something fundamentally wrong as I can't find a post that outlines the same issue.
Any ideas?
Cheers
Paul
|
|
|
|
|
I've just found out (by accident) that sub-reports in my version of BID do not preview - Once deployed they show up fine.
|
|
|
|
|
Guru's,
I have the following SQL query and it gives me back some syntactical errors and I am not familiar enough with Sql Server to understand exactly what it is I am doing wrong. Thanks in advance for an information!
ALTER TABLE BatchData
DROP CONSTRAINT PK_BatchData
ALTER COLUMN StartTime VARCHAR(50) NOT NULL
ADD PRIMARY KEY (BatchID,StartTime)
Gives error:
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'COLUMN'.
|
|
|
|
|
From what I can tell, you are trying to perform three actions:
drop constraint
alter column
add primary key
Each action must be completed separately, so:
ALTER TABLE BatchData
DROP CONSTRAINT PK_BatchData
ALTER TABLE BatchData
ALTER COLUMN StartTime VARCHAR(50) NOT NULL
ALTER TABLE BatchData
ADD PRIMARY KEY (BatchID,StartTime)
Does that help?
Tim
|
|
|
|
|
Member 8003276 wrote: ADD PRIMARY KEY (BatchID,StartTime)
Try:
ALTER TABLE BatchData
ADD CONSTRAINT PK_BatchData PRIMARY KEY (BatchID, StartTime);
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
When I run this:
DECLARE @voter_id INT
SET @Command = 'SELECT @voter_id = voterid FROM tblCamp_CT WHERE ' + @Query
EXEC (@Command)
I get the error
Must declare the scalar variable "@voter_id".
Why is this happening????
Everything makes sense in someone's mind
|
|
|
|
|
You must include DECLARE @voter_id INT inside single quotes.
e.g
SET @Command = 'DECLARE @voter_id INT SELECT @voter_id = voterid FROM tblCamp_CT WHERE ' + @Query
EXEC (@Command)
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.cacttus.com
|
|
|
|
|
But if I declare it in the @Command string, I cannot use @voter_id outside the string, correct?
I still get the same error message because @voter_id only exists in the string.
Everything makes sense in someone's mind
|
|
|
|
|
Absolutely.
Dasblinkenlight's solution is a nice one to the problem, BTW.
I normally build a temp table and just run the data into that. Using an insert or an update.
I know it seems (both suggested solutions) like a lot of overhead to get one piece of data out but that's really what it takes.
create table #Value (
val int
)
set @command = 'insert into #value (val) SELECT top 1 voterid FROM tblCamp_CT WHERE ' +@Query
exec(@command)
set @voter_id=(select top 1 val from #Value)
delete #Value
Like that.
You could also research sp_executesql for your project.
this works, for example:
declare @voter_id int , @query varchar(max), @command nvarchar(4000)
,@parm nvarchar(20)
set @query='1=1'
SET @Command = 'SELECT top 1 @voter_id = voterid FROM tblCamp_CT WHERE ' + @Query
set @parm ='@voter_id int output '
exec sp_executesql @command,@parm ,@voter_id out
select @voter_id test
As you can see the sp_executesql gives you another option.
Some of this depends on what your personal flavor is toward a given solution.
_____________________________
Give a man a mug, he drinks for a day. Teach a man to mug...
|
|
|
|