|
d@nish wrote: Sean Claude Van Dam
Jean
|
|
|
|
|
J4amieC wrote: Jean
I think Sean is the Irish one
|
|
|
|
|
I wasn't sure about the spelling. Hence I checked in google and got the results. Although I did not bothered to look down the page.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I have a service that needs to log into an SQL 2008 Express Server. The account of the service is the local system account. When the service starts, it checks if the SQL server is running. If not, it starts it, and waits for the service status to become "Running". When that has happened, the service logs in using a SqlConnection object.
If the login is done too fast, the SQL server reports "Cannot open database XXX requested by login. The login failed.". This indicates that the security subsystem of the database server is not in a running/complete state. No, I can see now that the database has not yet become online. My current approach is to hammer the database 10 times with 1 second interval to wait for the connection to succeed. This is idiotic, and just begs for sh*t to happen.
Does anybody know a better way? This is driving me insane...
--
Kein Mitleid Für Die Mehrheit
modified on Friday, October 16, 2009 5:15 AM
|
|
|
|
|
Can you not make your service depend on the SQL 2008 Express Server?
Check out the Dependencies tab on the control panel/services/properties page.
|
|
|
|
|
I could if I wanted to, but it doesn't help. The problem is that once the SQL server is reporting to be started to the SCM, it still hasn't made all databases online yet (only the master database is available). That work progresses after the SCM has been signalled that the service is running.
I found the solution to be easier than I thought. All I have to do is to
SELECT COUNT(*) FROM sys.databases WHERE name=@database_name AND state_desc='online' and see if it returns 0 or 1. Once the database manager reports the database as online, it is possible to use the database.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
Okay, I'm new here and to programming in general. I don't want to waste a lot of your time as I know the question I have has probably been asked before. I'm just not sure what to search for.
What I'm trying to do is create a site that displays a list of products from a database (which I know how to do) and when you click on the item it displays the product details (which is where I'm stuck). I've built a static html site at here so that you can get an idea of what I'm going for. As you can see there's quite an extensive description of the product which I haven't seen discussed how to create pulling from a database.
Any help would be greatly appreciated. Like I said, I know this has probably been discussed, so all I'm asking for is a point in the right direction. I'm not sure what I should be searching for. Thanks for your help in advance.
Also, I guess I should let you know that I know html and I know the basics of asp.net (c#). And I'm using Visual Studios 2008.
Again Thank You.
|
|
|
|
|
Well you got the wrong forum on your first attempt, the ASP forum will give you better results.
Here is a little Goole mojo[^] to get you started, the first result may be useful. There is a basic ASP tutorial around the demonstrates loading a grid and then using a details block to manage the CRUD on an item, that sounds like what you are after (sorry no link).
|
|
|
|
|
Sorry, I wasn't sure where to post since half of what I'm looking for is setting up the database for the product page and the other half is displaying it on the page. I looked at that link and I already know how to set that up. It's when links are clicked and I need a product page with 4-8 descriptions of the product that has me stumped. I guess I'll ask this over at the asp.net section. Thanks for your help.
|
|
|
|
|
Hi,
I am trying to insert into a DateTime field by concatenating a string and a nVarChar field like so:
CONVERT(datetime, '1/1/' + tblMembershipRecords.[YearJoined], 103)
But I get a message stating;
'Conversion failed when converting datetime from character string.'
Any ideas what is going wrong?
|
|
|
|
|
Liqz wrote: Any ideas what is going wrong?
The computer tries to "interpret" your string as a date, and it doesn't understand it. It seems that it expects the date to be in a different format.
Try something like this;
SELECT DATEADD(y, tblMembershipRecords.[YearJoined], getdate()) That will add a single year to the DateTime , without converting it to a string.
I are Troll
|
|
|
|
|
Got it, thanks for the tip, all working now
|
|
|
|
|
Good Day all
it is Probably a long day, i cant think Straight now.
i have a table that looks like this
Nodeid Parent Description Type Curr
==========================================================================================
89 NULL Compulsory 1 10
90 89 B1052 3 10
2820 89 One of 2 10
4113 89 B1061 3 10
2821 2820 B1054 3 10
2822 2820 B1055 3 10
Now the Bold Record needs to be on top of "One of" because the Parent is "Compulsary" with the "Parent" = 89. Now Even "One of " has the Same Parent as the Bold record but if its a "One of " and they have the same parent, then "One of " must always be below the record. What i mean is that if there is a record with a same parent but different Type , the one that has type 2 should go below the one that has type 3 in my query. here is my query
select distinct nP.id, nP.NodeID, nP.parent, nP.Description, nRef.ID refParent, np.type
from #Nodes nP
left outer join #Nodes nRef on nP.Parent = nRef.NodeID -- look up the reference id of the parent
order by refParent,nP.id,np.type desc
Thank you
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thanks now i have Changed my Code to look like this and its working perfect in SQl when i test it.
select distinct nP.id, nP.NodeID, nP.parent, nP.Description, nRef.ID refParent, np.type
from #Nodes nP
left outer join #Nodes nRef on nP.Parent = nRef.NodeID -- look up the reference id of the parent
order by np.Parent,np.Description,np.NodeID
And it returns
Nodeid Parent Description Type Curr
==========================================================================================
89 NULL Compulsory 1 10
90 89 B1052 3 10
4113 89 B1061 3 10
2820 89 One of 2 10
2821 2820 B1054 3 10
2822 2820 B1055 3 10
and its Good thanks.
am binding the values to a Tree Control like this
public void PopulateTreeFromCurr(int currID)
{
IEnumerable result = CurrStructDataSource.Select(DataSourceSelectArguments.Empty);
int Parent, Child;
CurriculumTreeView.Nodes.Clear();
ArrayList CurrNodes = new ArrayList();
if (result != null)
{
foreach (System.Data.DataRowView row in result)
{
TreeNode newnode = new TreeNode(row["Description"].ToString(), row["NodeID"].ToString());
CurrNodes.Add(newnode);
if (row["refParent"].ToString() == "")
{
}
else
{
Parent = Convert.ToInt32(row["Parent"]);
Child = Convert.ToInt32(row["ID"]);
TreeNode ParentNode = new TreeNode();
TreeNode ChildNode = new TreeNode();
[COLOR="DarkOrange"][B]ParentNode = (TreeNode)CurrNodes[Parent];[/B][/COLOR]
ChildNode = (TreeNode)CurrNodes[Child];
ParentNode.ChildNodes.Add(ChildNode);
CurrNodes[Parent] = ParentNode;
}
}
if (CurrNodes.Count > 0)
{
CurriculumTreeView.Nodes.Add((TreeNode)CurrNodes[0]);
CurriculumTreeView.ExpandAll();
}
}
}
in the code i get an Error in the bolded red part line
ParentNode = (TreeNode)CurrNodes[Parent];
and it says
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Thank you
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
select ROW_NUMBER() OVER (ORDER BY pid DESC) as RowNum, pid,grpname from
(select distinct p.ParticipantId as pid,p.pname + ' (' + p.username + ' )' as grpname from
TSParticipants as p inner join TSGroupParticipants as gr
on p.ParticipantId=gr.ParticipantId
where p.status=0) as grplist
in the above query i have to add the the below where condition
WHERE RowNum BETWEEN 0 AND 0 + 6 -1
where should i add this condition
if add it its showing error:
Msg 207, Level 16, State 1, Line 8
Invalid column name 'RowNum'.
Msg 207, Level 16, State 1, Line 8
Invalid column name 'RowNum'.
--------------------------------
select * from
( select *, row_number() over (unique_column_name order by asc) as rownum from emp ) as test where rownum between 0 and 0 + 6 -1
-----
this above query gives all the rows
i need only unique rows
|
|
|
|
|
I have created a sample example. Hope this may help you.
declare @tbl table(firstname varchar(50),lastname varchar(50))
insert into @tbl
select 'firstname' + CONVERT(varchar(50),column_id)
,'lastname' + CONVERT(varchar(50),column_id)
from sys.columns
select * from @tbl
select firstname,lastname from
(select ROW_NUMBER() over(order by firstname) as rn,firstname,lastname
from
(
select
distinct(firstname),lastname
from @tbl t
)X(firstname,lastname))Y(rn,firstname,lastname)
where rn between 0 and 0 + 6 -1
As per the understanding I made after going thru ur statement, I thought that u r looking for unique records. Henceforth, in the very beginning only I have used a distinct clause.
Note:- I tried to explain the concept. You need to customise and implement as per ur requirement.
Let me know in case of any concern.
I cannot make out why instead of using 5 directly u are using 0+6-1?
Niladri Biswas
|
|
|
|
|
Hi,
I'm working on replication. It's working fine for same network sql servers.
But when i'm using one remote server then at the time of creating subscription it's not able to connect the remote sql server.
Plz tell me how to fix this issue..
Thanx...
krishna veer singh
|
|
|
|
|
I am trying to OUTPUT a data from the SP but getting this error:
System.InvalidOperationException was unhandled
Message="String[5]: the Size property has an invalid size of 0."
Source="System.Data"
StackTrace:
at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc)
at System.Data.SqlClient.SqlCommand.SetUpRPCParameters(_SqlRPC rpc, Int32 startCount, Boolean inSchema, SqlParameterCollection parameters)
at System.Data.SqlClient.SqlCommand.BuildRPC(Boolean inSchema, SqlParameterCollection parameters, _SqlRPC& rpc)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at The_Internet_Cafe_System.frmMain.connect_to_host() in C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Internet Cafe\Internet Cafe\main_form.cs:line 206
at The_Internet_Cafe_System.frmMain.timerHost_Tick(Object sender, EventArgs e) in C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Internet Cafe\Internet Cafe\main_form.cs:line 496
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at The_Internet_Cafe_System.Program.Main() in C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Internet Cafe\Internet Cafe\Program.cs:line 35
InnerException:
this is my SP:
USE the_internet_cafe
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[sp_update_account_on_host]
@system_guid uniqueidentifier,
@net_qty int,
@net_amount money,
@items_qty int,
@items_amount money,
@banner_file varchar(255) output
AS
BEGIN
SET NOCOUNT ON;
UPDATE internet_cafe SET net_qty = @net_qty, net_amount = @net_amount, items_qty = @items_qty, items_amount = @items_amount, last_connected = getdate() WHERE system_guid = @system_guid
SET @banner_file = (SELECT banner_file FROM banners WHERE banner_id = 1)
END
and this is my C# code:
private void connect_to_host()
{
sql_connection = new SqlConnection("Data Source=.\\TICSSQL;initial catalog=the_internet_cafe;integrated security=true;");
sql_connection.Open();
sql_command = new SqlCommand("sp_update_account_on_host", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("@system_guid", SqlDbType.VarChar).Value = Properties.Settings.Default.system_net_cafe_guid;
sql_command.Parameters.Add("@net_qty", SqlDbType.Int).Value = Properties.Settings.Default.system_net_qty;
sql_command.Parameters.Add("@net_amount", SqlDbType.Money).Value = Properties.Settings.Default.system_net_amount;
sql_command.Parameters.Add("@items_qty", SqlDbType.Int).Value = Properties.Settings.Default.system_item_qty;
sql_command.Parameters.Add("@items_amount", SqlDbType.Money).Value = Properties.Settings.Default.system_item_amount;
SqlParameter banner_file = sql_command.Parameters.Add("@banner_file", SqlDbType.VarChar);
banner_file.Direction = ParameterDirection.Output;
int result_rows = sql_command.ExecuteNonQuery();
MessageBox.Show(banner_file.Value.ToString());
sql_connection.Close();
|
|
|
|
|
jrahma wrote: sql_command.Parameters.Add("@banner_file", SqlDbType.VarChar);
It seems fairly obvious, add a size
sql_command.Parameters.Add("@banner_file", SqlDbType.VarChar, 255);
only two letters away from being an asset
|
|
|
|
|
Hi.
I just wanted to let you know that db4o has improved its memory manager making it more appealing to .NET & Java developers who work in memory constrained environments. In memory usage of db4o is now more closely integrated with the storage API which removes redundancies while bringing better support for administrative features such as defragment and backup. The new PagingMemoryStorage implementation significantly reduces memory footprint.
More info:
http://developer.db4o.com/blogs/product_news/archive/2009/08/13/memories-running-db4o-in-memory-revisited.aspx
Best!
|
|
|
|
|
I think you should pay to advertise like others have to...
|
|
|
|
|
Hi,
Which method is the best way to transfer realtime data from one sqlserver to another sqlserver.
Plz let me know..
Thanx...
krishna veer singh
|
|
|
|
|
|
If you are using 2005 or greater then you should look at Sql Server Service Broker as it was designed specifically for your requirement.
|
|
|
|
|
Do you mean transfer or replicate? For the former, assuming sql server 2005 or later, useService Broker, for the latter google replication.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|