|
You are not using integrated windows security. Make sure that the SQL LogIn is a user in the db_datareader role in the database and you should be good to go.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
How to return first 10 rows in a table using the select command in SQL?
|
|
|
|
|
SELECT TOP [rownumber] [col1][, col2]...
FROM [table]
e.g. SELECT TOP 10 name FROM tblNames
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia
|
|
|
|
|
you can use order by to select on a defined order of a column
<br />
select Top 10 * from table<br />
order by created_date <br />
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
SELECT * FROM table where ROWNUM < 10 ORACLE
SELECT TOP 10 * FROM table SQL Server
SELECT * FROM table LIMIT 10 MySql Also
SELECT * FROM table LIMIT 10 OFFSET 50
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
i am trying to write a script. i need to copy the contents of my clipboard into a text file. then i need to save the text file as a htm file extention with a different name then i need to close both of the files. basically what i am doing is saving web page code in a filemaker pro data base. and i want to take the contents of a field that contains my code. and save itr as a htm file. is there any scripting language that will allow me to do this.
thanks in advance for any responses
|
|
|
|
|
Try APS.NET, Windows, C# or VB
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
weelze wrote: is this the right forum
Not really
weelze wrote: basically what i am doing is saving web page code in a filemaker pro data base. and i want to take the contents of a field that contains my code. and save itr as a htm file.
Sure, shouldn't be terible difficult with a scripting language such as VBS (Visual basic Scripting), the MSDN has a bunch of examples.
Visual Basic Scripting[^]
I'd love to help, but unfortunatley I have prior commitments monitoring the length of my grass. :Andrew Bleakley:
|
|
|
|
|
I want to add a new row to my datatable,then set this row is Currentrow
in BindingContext, so i change the BindingContext.Position for moving to the new row.
I have two forms,I can change the "BindingContext[mydatatable].Position" in one form ,but this cannot be implemented in another form .Who can tell me why?The code is:
DataRow dr = GdtKeyPoint.NewRow();
GdtKeyPoint.Rows.Add(dr);
this.BindingContext[GdtKeyPoint].Position = GdtKeyPoint.Rows.Count;
//or this.BindingContext[GdtKeyPoint].Position = GdtKeyPoint.Rows.Count-1;
//also can`t be implement. no error was raising!!
|
|
|
|
|
Are you using .Net 2.0? If yes, then try using BindingSource instead.
If not, then try working with the CurrencyManager instead of the BindingContext.
[edit]You can get the CurrencyManager from the BindingContext, and that's supposed to be the object that you edit instead./edit]
"A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson
"Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin
Edbert
Sydney, Australia Last modified: Tuesday, 1 August 2006 01:32:54 --
|
|
|
|
|
To Edbert:
Thank you very much,I am using .net 2.0. but I just a freshman for it. I will try the method your words concerned .My English is poor, but I hope you'll understand what I said.
|
|
|
|
|
Hi,
using C#;
using VS2005;
I have a dataset that contains several datatables. What I wish to do is search each row in one of the tables and read/copy the value of a column into a variable. I will then manipulate the variable as needed. Specifically, the dataTable is "MembershipDetails" and the column is "MembershipNumber". The dataset is called "myclubDataSet".
The purpose of all this is to determine the next sequential membership number.
If someone could be so good enough to write the code for me I would very much appreciate it because I can't find a simple straightforward example anywhere on the net to learn from.
I know how to do a sql command to do this but I don't want to do it on the database. I wish to achieve it using the dataset.
Thanks in advance.
Glen Harvy
|
|
|
|
|
This seems a very hard way to do a simple task.
Run following sql code to get a last membership number
<br />
select top 1 MembershipNumber<br />
from myclubDataSet<br />
ORDER BY MembershipNumber DESC<br />
This will no however stop two user from trying to create the same membership number after getting the same last number from the database.
What you really want to do is return the membership number after creation
Make 'MembershipNumber' and identity column on your database and use similar codeas below,
<br />
insert membername, memberdetails<br />
VALUES ('Joe Bloggs', '15 Anyplace Road')<br />
<br />
SELECT @@Indentity<br />
<br />
The select @@Indentity will get the newly created memebership number. Try it in SQL before you try and code it.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Thanks for your asistance - much appreciated.
Frank Kerrigan wrote: This seems a very hard way to do a simple task.
That seems to be the way I do everything nowadays .
I have some database/SQL experience with designing websites that use databases and understand your suggestions pretty well BUT I need to achieve my aim without going back to the database. I really want to learn how to retrieve the value of a column in each row or specific row.
With a bit of help from elsewhere I've got as far as:-
DataTable table = myclubDataSet.Tables["MemberDetails"];
DataRow[] foundRows;
foundRows = table.Select("MembershipNumber > 1 ");
for (int i = 0; i < foundRows.Length; i++)
{
int num = System.Convert.ToInt32(foundRows["MembershipNumber"]);
MessageBox.Show("Membership number is: " + num);
}
But this leads to a build error message:
Error Cannot implicitly convert type 'string' to 'int'
with the culprit being MembershipNumber even though that column is defined as an Int32 in the datatable.
I hope you can see what I'm trying to learn to do and can just help me over this hurdle
Thanks,
Glen Harvy
|
|
|
|
|
|
After much, much searching and a bit of a hint here, a bit of false leading there and a lot of building I ended up achieving what I wanted as follows:
private void defaults()
{
this.memberDetailsTableAdapter.Fill(this.myclubDataSet.MemberDetails);
int totalRows = myclubDataSet.MemberDetails.Rows.Count;
short maxMemNum = 0;
short nextMemNum = 0;
for (int i = 0; i < totalRows; i++)
{
short MemNum = (short)myclubDataSet.Tables["MemberDetails"].Rows[i]["MembershipNumber"];
if (MemNum >= maxMemNum)
{
maxMemNum = MemNum;
nextMemNum = ++maxMemNum;
MemNum = nextMemNum;
}
}
this.editMembershipNumber.Text = nextMemNum.ToString();
}
Glen Harvy
|
|
|
|
|
Use Master
GO
RESTORE DATABASE Central Coast from disk = 'C:\centralcoast_db_200602020948.BAK'
with MOVE 'centralcoast_Data'
TO 'd:Z_centralcoast_Data.MDF',
MOVE 'centralcoast_Log' TO 'd:\Z_centralcoast_Log.LDF',
stats = 1
STOPAT = 'Feb 02, 2006 06:00 AM'
I'm trying to restore this Database up to a specific date and time but form some reason I geting an error saying "error missinf syntax after 'FROM' "
Greg
Coding makes the world go round!!!
|
|
|
|
|
Just guessing that the space character between Central and Coast is causing the problem. Try
RESTORE DATABASE 'Central Coast' from disk = 'C:\centralcoast_db_200602020948.BAK'
or is the database called 'CentralCoast'?
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Yeah, the DB's name is CentralCoast.
Greg
Coding makes the world go round!!!
|
|
|
|
|
Try placing a comma after stats=1.
RESTORE DATABASE 'Central Coast' from disk = 'C:\centralcoast_db_200602020948.BAK'
with MOVE 'centralcoast_Data'
TO 'd:Z_centralcoast_Data.MDF',
MOVE 'centralcoast_Log' TO 'd:\Z_centralcoast_Log.LDF',
stats = 1,
STOPAT = 'Feb 02, 2006 06:00 AM'
[edit] and the space in dbname, like Chris said [/edit]
-- modified at 15:53 Monday 31st July, 2006
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
How do I Insert a copy of a record when I want to change ONLY one field..
INSERT INTO tb
SELECT field1, field2, field3, field4, field5
FROM tb AS tb_1
WHERE (field1 = @Value)
None of the selected items are the primary key, and this insert works fine for a perfect clone, but I need to be able to modify field1 with a textbox the user can type in.
I know there is VALUE keyword.. but I can't seem to get it to work for just field1.
|
|
|
|
|
INSERT INTO tb
SELECT @someValue, field2, field3, field4, field5
FROM tb AS tb_1
WHERE primaryKey = @primaryKey
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
|
Hi all
I'm moving an VB6 app to .NET and i'm faced with the following problem:
Having the following stored procedure in SQL SERVER 2000, that returns a dataset (Read only) AND has an OUTPUT parameter at same time, which of the command methods should i use, since it seems that ExecuteReader (Thats seems to be the only that returns a rowset) doesnt update the OUTPUT parameter.
Im I missing something?, Is there Any work Around?
'==============================================================================
ALTER PROCEDURE spGetResourceText (@frmName varchar(20),@MaxIndex int OUTPUT)
AS
SET NOCOUNT ON
SELECT @MaxIndex = Max(Id) FROM tblResourceText WHERE frmName = @frmName
SELECT * FROM tblResourceText WHERE frmName = @frmName
RETURN
'==============================================================================
Thanks in advance for your time!
Carlos Paiva
|
|
|
|
|
I'm not sure why the output parameter has not been updated but there are many workarounds.
1. Use two stored procs and call them each.
2. Change select statements to
SELECT @MaxIndex = Max(Id) FROM tblResourceText WHERE frmName = @frmName
SELECT *, @MaxIndex as MaxIndex FROM tblResourceText WHERE frmName = @frmName
then the MaxIndex is returned in your dataset or datareader.
I could go on but I think you'll figure it out.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|