|
Exposing production data for analysis is fraught with nightmares. Business analysis is a monster and should only be done against a data wharehouse so the first thing you need to look into is wharehousing strategies. They will depend on your data size, replication speed requirement and budget.
Once you have sorted that then connection to the wharehouse is trivial. Designing the wharehouse on the other hand is an entire career.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
suppose i am developing a site with ASP.Net MVC core. i have created a empty project where i add two controller.
one is Home and login controller. Home controller's index action is not protected by Authorized attribute but Home controller's product action is protected.
when user try to access product action then user should be redirected to login page if not signed in. so tell me how to setup project in classic mvc or mvc core where i will mention that user should be redirected to login page if user is not signed in.
i will not use identity rather i will check user credentials from db using ado.net.
please guide me step wise that what i need to follow. Thanks
|
|
|
|
|
|
Sir, my question was bit different. i am trying to know how asp.net mvc engine understand now user need to redirect to login page? if login controller name would be different then how asp.net mvc understand it ? where this binding done in default project when we create a default project from IDE?
i believe there must be a place where we mention that login page should come if user is not signed in when access any protected resource.
please share knowledge if you know. thanks
|
|
|
|
|
|
Please see the code.
using (Html.BeginForm("Login", "Default", new { ReturnUrl = ViewBag.ReturnUrl, data = Request.QueryString["data"] }, FormMethod.Post,
new
{
id = "idtest1",
onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",
@class = "form-signin",
role = "form"
}))
{
}
specially see this line which is not clear to me. onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",
in the above code BeginForm html helper has been used to render form at runtime. what will happen when form will be submitted ?
what this line will do when form submit ? onsubmit = "this.querySelectorAll('button').forEach(i => i.disabled = false)",
please help me to understand this JavaScript code objective when form submit. Thanks
|
|
|
|
|
That line sets the onsubmit attribute on the <form> element to the specified Javascript string. It's an old way of attaching an event handler to an element.
When the form is submitted, all buttons on that form will have their disabled property set to false . But that won't actually accomplish anything; a button's name and value are only submitted with the form if you click on that button, and you can't click on a disabled button.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sir, thank you so much for reply.
|
|
|
|
|
Hello,
Quick intro, My name is Jason and recently a work colleague retired and had developed several ASPX websites of which I have been tasked to support.
My previous background of programming is around Delphi, Intersystems Cache and more recently C# but these websites that I'm now supporting are all written in VB.net, asp.net, aspx or whatever language it is called, as you have probably guessed by now I have never used Visual Studio or produced code that created aspx files.
Anyway as a newbie to this language I have run into a problem that you experts will have learnt in school
I have a webpage (student.aspx) that contains this snippet of code :
<asp:DropDownList runat="server" ID="ddlCourse" DataTextField="Course"
DataValueField="Course" DataSourceID="SDSCourse"
Width="260px" onChange="CheckNerveCenter"/>
I have added the "onChange" bit
and this bit of code is also existing
<asp:CheckBox ID="chkNerveCentre" runat="server" Text="Nerve Centre" TextAlign="Left" />
So basically the page contains several combo boxes and several check boxes
I need to do some logic for 2 of them, code above.
If the combo box contains text (from database) with the word Nursing, Nurse, Nurses etc. lets say "*Nurs* then teh tick box needs to be disabled so it cannot be ticked
This is the code I have done in the code behind file student.aspx.vb, it just contains a comment now
Function CheckNerveCenter() As Object
'If ID="ddlCourse" contains any word like "*Nurs*" then
'uncheck ID="chkNerveCentre" and then disable ID="chkNerveCentre"
End Function
At first I tried to get it to display a message to show that it was calling the function from the "onChange" but it doesn't seem to work.
As I'm new to this language would you please just help a newbie in the right direction
I did try and use the OnChangeText in visual studio but it just kept showing me this error
"Property Value not valid","Error HRESULT E_FAIL has been returned from a call to a COM component." I have no idea what this means
That's why I decided to try and use a function of my own but now stuck
Any ideas please?
Jason
modified 7-Jul-22 7:31am.
|
|
|
|
|
The OnChange event will run on the server, when the page posts back to the server. That normally only happens when you click a button; if you want it to happen as soon as your list changes, you'll need to set the AutoPostBack property of the list to True .
ListControl.AutoPostBack Property (System.Web.UI.WebControls) | Microsoft Docs[^]
Your event handler method will need to match the expected signature:
Protected Sub CheckNerveCenter(ByVal sender As Object, ByVal e As EventArgs)
...
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
if you know than described the code
|
|
|
|
|
No, there isn't.
Your C# code will be running on the server. At best, you would capture a screenshot and system information of the server, which would not be much use.
The only code that runs on the client is your Javascript. And that has extremely limited access to the system it's running on, for obvious security reasons.
There is a Javascript screen capture API, but it requires the user to grant your site access to use it:
Using the Screen Capture API - Web APIs | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I write a page and use TempData to transfer information to other view.
the code like this
TempData["TP"]=tpDoc; //tpDoc is a xml file
In another view, I use
System.Xml.XmlDocument tpDoc = TempData["TP"] as System.Xml.XmlDocument;
above code is working in VS2019. But after I deploy to website, there is error:
Error.
An error occurred while processing your request.
so what is wrong in the code? Why it works in VS2019 and failed on Server?
|
|
|
|
|
You need to find out what the actual error is. Trying to diagnose a problem based solely on "an error occurred" is never going to work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The most common problem is that the file that loads into tpDoc is not where you think it is on the server or you do not have permissions to access is.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
SELECT DISTINCT does not work the way I want.
SELECT DISTINCT works for the class column but not for name_event column
If "MyId" is e.g. CW and there are 4 lines there but name_event should only be 2 pcs, but it shows 4 pcs
Now display:
World Championships
French Champioships
World Championships
World Championships
It should be:
World Championships
French Champioships
What am I doing wrong?
<pre> Dim MyDataAdapter As New SqlDataAdapter("SELECT DISTINCT class, nationality, name_event from statistics_results Where class = @class", MyConnection)
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@class", SqlDbType.VarChar, 10))
MyDataAdapter.SelectCommand.Parameters("@class").Value = MyId
Try
Dim dt As New DataTable()
MyDataAdapter.Fill(dt)
Dim natlist = dt.AsEnumerable().[Select](Function(r) r("nationality").ToString())
Dim natvalue As String = String.Join("- ", natlist)
litNat.Text = natvalue
Dim eventlist = dt.AsEnumerable().[Select](Function(r) r("name_event").ToString())
Dim eventvalue As String = String.Join("<br>", eventlist)
litEvent.Text = eventvalue
Catch exc As SqlException
Finally
MyConnection.Close()
MyConnection.Dispose()
End Try
|
|
|
|
|
What is your data?
kjell.ek wrote: SELECT DISTINCT class, nationality, name_event from statistics_results Where class = @class
All three columns (Class, Nationality, name_event) make it distinct. if you look at the data, those 4 rows are distinct from each other when you include all columns.
In other words if you do a
SELECT DISTINCT name_event from statistics_results Where class = @class
You will get two rows.
HTH
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Hello Kjell.ek !
as distinct can be apply on one column,
you can use it this way :
SELECT id, distinct(name_event), class, nationality from statistics_results;
the sql engine will keep in the record with each name_event only one time.
DISTINCT statement acts at column level.
|
|
|
|
|
The OP is using a SqlDataAdapter , which means they're using Microsoft SQL Server.
That is not how DISTINCT works in SQL Server.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry I missed the data source, yes I use MS SQL server. Have tried the variants above but I get the wrong number of "name_event"
I get numbers according to how many rows there are in the selected class.
This is how it will be at a selected class. It should be 1 World Championships note 6
Tips on how to solve it?
World Championships
World Championships
World Championships
World Championships
World Championships
World Championships
DEU - FIN - FRA - NOR - POL - SWE
modified 6-Mar-23 8:07am.
|
|
|
|
|
Can you show what the result set is without the distinct please..
SELECT class, nationality, name_event from statistics_results Where class = 'xx'
|
|
|
|
|
Having trouble importing competition results from Excel to MS SQL Server with Asp.Net. Worked well until I added milliseconds. They are lost on import. Anyone with good tips on what the problem is?
MS SQL server Data Type: time(7)
Excel formatting for time results (Swedish Excel): tt:mm:ss,0
In asp.net
MyCommand.Parameters.Add(New SqlParameter("@total", SqlDbType.Time, 7))
MyCommand.Parameters("@total").Value = Trim(rad("Total"))
Time in Excel: 00:26:32,4
In SQL server: 00:26:32
I lost the milliseconds.
|
|
|
|
|
That Trim call suggests you're treating the data as a String . You should parse it to the correct type (TimeSpan ) before passing it to SQL.
Since your data is formatted for a culture which uses the comma as the decimal separator, you will need to ensure you use the correct CultureInfo when you parse the value.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the tip
|
|
|
|
|
Format 109 is like "Jun 17 2012 2:00:29:147PM", so obviously [Start Date] is varchar already before the convert.
I suspect that that problem is that Excel thinks that this is a datetime value, and that's why the milliseconds are lost in transport. Excel is not really the best venue for strict data-typing, but rather the drivers makes some guesswork. You could try to format the column as text, but I am not sure it would help.
I never use OPENROWSET/OPENDATASOURCE to read Excel files myself. For one-offs I save the file as a CSV and import it with BCP. For imports on regular basis, I would write a client program for the task. Many people would go for a soluton with Integration Services.
|
|
|
|