|
Hi, can u post the error?
|
|
|
|
|
ExecuteScalar:Connection property has not been initialized
Known Is Drop.Unknown Is Ocean
|
|
|
|
|
Hi,
i need to know about 2 things.
1. Is there any way or article which shows u how to create a floating panel... that is consider a textbox to enter model name, somebody enters acer 1600 (acer brand, 1600 portion of model) and a panel appears (populated from tables 1. brand table 2. models)... Did you mean
Acer Aspire 1600
Acer Aspire 1600Z
Acer somemodelname 1600
and then a person choses one , this panel disappears, giving details of the model.. such panels are used in monster.com for login...
2. I am using linq and the sql table has 30000 rows, i know that i should do paging for the gridview but my client needs the application... he is not willing to give me time for that, project has been developed by somebody else and when u press search btn , it takes time to load the data, i want to insert a progress bar (it should not be a 0-100% progress bar... it can be something in javascript)...coming to the question... i simply added a label, just above the retrieval code, did the following
gridvu.datasource=null;
gridvu.visible=false;
lbl.text="Loading please wait";
but the previous gridview did not disappear, lbl was never displayed... Why?
thanx for helping...
|
|
|
|
|
Hello,
I am making first ever asp.net application and added lblusername,txtusername,lblpassword,txtpassword and btn signin in the master page for login purposes. i then provided functionality for the login (i have worked with desktop apps), when user found, copied his name to session and well, this worked...
but as i am still developing the application , i want my application to be signed in when i run it so i decided to provide the code in pageload of master page, which was there ( i don't know how this event was added) and it didn't work... searching through the methods and internet allowed me to know that there was a function onloadcomplete of page... i tried alot but i can't override this event... i don't get it in intellisense when i write override, also how do u add the init functions and events for a page...
Thanx for helping... i think, this question is probably very stupid but being a desktop application developer, i think asp.net can be very confusing...
please provid help
|
|
|
|
|
Hi, can u post your code?
If a user login in your page successfully log. then ur masterpage displayed
On your masterpage load event you can write this
txtUsername = sessiont("userName")
|
|
|
|
|
oh, Code!, i am working with a company and developing the application there for that i will have to wait till monday but there is nothing special in the code, ( (this portion was developed by previous programmer) masterpage.master has the login controls and a btn in a panel, this panel disappears when a successful login hapens and all the links appear , each link when clicked looks whether a session is created or not... simple as that... but as i have to continue developing it, i am thinking to add some code so that i am logged in when i run the application.. i can disable the panel and show the links panel directly but i don't want to do that, i want session to be created as soon as default.aspx loads but how ... that is where i need help...
thanx for replying
|
|
|
|
|
I have a gridview loaded from an sql datasource then in an item template in the gridview I have a dropdownlist that is supposingly loading from another sql datasource having the property datakeys of the gridview as its control parameter name.
meaning: each row has a ddl that takes its datakey as parameter to display results form another sql datasource;
and I have set the datakeynames of the gridview to be "OrderId" the pk that I want to use as the parameter. The idea is that I want to use the datakeys property of the gridview instead of selecteddatakey coz I want the user to have all data loaded once without the need to postback everytime he selects a row ...
the first sql datasource is loading the data into the gridview without any problem but when I assign the sqldatasource to the ddl the following error appears:
Type 'System.Web.UI.WebControls.DataKeyArray' in Assembly 'System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable.
code for gridview:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="OrderId"
DataSourceID="SqlDataSource1" CellPadding="4" DataMember="DefaultView"
ForeColor="#333333" GridLines="None" PageSize="15">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:BoundField DataField="OrderId" HeaderText="OrderId" ReadOnly="True"
SortExpression="OrderId" />
<asp:BoundField DataField="FullName" HeaderText="FullName" ReadOnly="True"
SortExpression="FullName" />
<asp:BoundField DataField="Time" HeaderText="Time" SortExpression="Time" />
<asp:BoundField DataField="Comments" HeaderText="Comments"
SortExpression="Comments" />
<asp:BoundField DataField="Region" HeaderText="Region"
SortExpression="Region" />
<asp:BoundField DataField="Street" HeaderText="Street"
SortExpression="Street" />
<asp:BoundField DataField="PhoneNumber" HeaderText="PhoneNumber"
SortExpression="PhoneNumber" />
<asp:BoundField DataField="Total" HeaderText="Total" ReadOnly="True"
SortExpression="Total" />
<asp:TemplateField HeaderText="Order">
<ItemTemplate>
<asp:DropDownList ID="DropDownList3" runat="server"
DataSourceID="SqlDataSource3" DataTextField="LIST" DataValueField="LIST">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
code for the ddl datasource:
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
SelectCommand="SELECT CAST(OrderDetails.Quantity AS varchar(3)) + ' ' + Menu.Name+ ' ' + CAST(OrderDetails.UnitPrice AS varchar(7)) AS LIST FROM Menu INNER JOIN OrderDetails ON OrderDetails.ItemId = Menu.ID WHERE (OrderDetails.OrderId = @OrderId)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="OrderId"
PropertyName="DataKeys" />
</SelectParameters>
</asp:SqlDataSource>
I want to load the ddl3 without the use of selectteddatakey(and the event selectedindexchanged) just with the help of datakeys and some code if needed and I will apreciate any help coz I am working on this for days and I'm beginning to think it's a bug coz everything seams to be ok untill the lovely error appears. be precise!I need your help, thank you
|
|
|
|
|
Hey all,
The RegistryKey refers to Microsoft.Win32.RegistryKey and I am on Windows Server 2003 with 64 bit. Do you all know if there is a reference for Microsoft.Win64.RegistryKey?
The code looks like this now...debugging it shows that the value of serverName is NULL(no kidding Wink )
<br />
public string RetrieveDataSource<br />
{<br />
<br />
get<br />
{<br />
try<br />
{<br />
System.Data.Sql.SqlDataSourceEnumerator en = System.Data.Sql.SqlDataSourceEnumerator.Instance;<br />
DataTable dt = en.GetDataSources();<br />
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");<br />
String[] instances = (String[])rk.GetValue("InstalledInstances");(This is NULL)<br />
<br />
if (instances.Length > 0)<br />
{<br />
foreach (string element in instances)<br />
{<br />
if (element != "MSSQLSERVER")<br />
{ serverName = String.Format(System.Environment.MachineName, element); }<br />
else<br />
{ serverName = System.Environment.MachineName; }<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
catch (Exception ex)<br />
{<br />
ex2 = ex.Message;<br />
}<br />
return serverName;(This is NULL)<br />
}<br />
<br />
}
Is there any other way of getting the instance name without this roundabout? Seemed pretty straight forward to me before i coded...now not so much.
I can get the machine name directly by System.Environment.MachineName; if only there is a way to retrieve Instance name without RegistryKey hassle..i would avoid this method totally.
Thanks to Sandeep, Rolcr, Disgyza and Colin Angus Mackay for helping
Swetha
|
|
|
|
|
I posted this on a different thread of yours but I figured I'd post it here as perhaps a different approach to your problem. I'm not entirely sure if this will work for you, but you can certainly give it a shot.
You could try using this:
using(Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer m = new Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer())
{
foreach (ServerInstance si in mc.ServerInstances)
{
Response.Write("ServerInstance:" + si.Name + "
");
}
}
You'll probably have to add a Reference to Microsoft.SqlServer.Smo
Best of luck
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
Though it seemed like it would work, it showed error in ServerInstance keyword. Added a bunch of assembly reference
using Microsoft.SqlServer.Management.Smo.Wmi;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Smo.RegisteredServers;
Looks like i'm pretty close, if only i could figure out how to find the sql server instance running, i'll be all set to post an article about the exercise
Swetha
|
|
|
|
|
public string RetrieveDataSource<br />
{<br />
get<br />
{<br />
try<br />
{<br />
System.Data.Sql.SqlDataSourceEnumerator en = System.Data.Sql.SqlDataSourceEnumerator.Instance;<br />
DataTable dt = en.GetDataSources();<br />
RegisteredServer[] rsvrs = Microsoft.SqlServer.Management.Smo.SqlServerRegistrations.EnumRegisteredServers();<br />
foreach (RegisteredServer rs in rsvrs)<br />
{<br />
serverName = rs.ServerInstance;<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
ex2 = ex.Message;<br />
}<br />
return serverName;<br />
}<br />
}
The returned string is "machine name"\sqlexpress.
Atleast this returns something instead of object reference error.
Now the next question is, the Sql server instance the solution is accessing is MSSQLSERVER2008, now why would it show Sqlexpress in the output? If the answer is because its default, how to find the instance which is being currently used.
Thanks.
Swetha Sankaran
|
|
|
|
|
You should probably verify that there is only one ServerInstance being returned.
Because you are using a foreach loop and overwriting the serverName value it will always show you the last ServerInstance.
If you have more than one ServerInstance this may become a problem.
Perhaps you can store the value of the ServerInstance in the Web.config file in the AppSettings?
I'm heading home for the weekend and won't be able to check up on this post anymore until Monday. I wish you the best of luck Swetha. I'm sure you will find a solution.
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
Hi Swetha,
I got the results you were looking for.
In my case this returns more than one instance. But it does work.
Try using this
Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer mc = new Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer();
foreach (Microsoft.SqlServer.Management.Smo.Wmi.ServerInstance si in mc.ServerInstances)
{
Response.Write("ServerInstance: " + si.Name);
}
In my case it returns two instances
MSSMLBIZ
SQLEXPRESS
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
Hey cool..will try it rightaway...thanks disgyaza. You have an awesome weekend!!
Swetha
|
|
|
|
|
Stop posting and deleting
Alexei Rodriguez
|
|
|
|
|
I WILL continue to update the code and WILL delete that which is obsolete. The code that was deleted were updated and posted back based on further research and modifications.
Swetha
|
|
|
|
|
swetha sankaran wrote: The code that was deleted were updated and posted back based on further research and modifications.
It looks like you have no idea of what this forum is for
First do "research", then if you dont find the answer, then post, and let the post grow as more people enriches the post
If you continue doing that, i WILL block your account for posting
Alexei Rodriguez
|
|
|
|
|
|
Thats what dubug the application and check which object is null ..
swetha sankaran wrote: String[] instances = (String[])rk.GetValue("InstalledInstances");
Make sure that
rk is not null have if block there and check if (rk != null ) then do that
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
Check My Blog
|
|
|
|
|
Does that key exists on your box? on mine with sql2005 it doesnt...
|
|
|
|
|
I think the right path is :
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server");
|
|
|
|
|
Perhaps you need to create a new instance of your RegistryKey.
Try the using key word
using(RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft SQL Server"))
{
String[] instances = (String[])rk.GetValue("InstalledInstances");
}
Not entirely sure if that will work for you.
Good luck
Cheers
Disgyza
Programmer Analyst
|
|
|
|
|
|
if have problems getting machine name use:
string name=Environment.GetEnvironmentVariable("computername");
|
|
|
|
|