Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

miss786

@miss786
About
Posts
100
Topics
39
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How create a cross domain web api?
    M miss786

    I am trying to create cross domain web api, however I am still unable to call data from web api url, in my ajax function. I am currently experiencing the following syntax error, under the networks, response tag. **SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data** The ’/ api/stw’ is currently being reported as 405 error, however when I call - http://apitesting.domain.com/api/stw, I am able to see the data is JSON format. So, I am little unsure, why is it failing in the ajax function.

    $(document).ready(function () {
    $.support.cors = true;
    $.ajax({
    type: "GET",
    crossDomain: true,
    contentType: "application/json; charset=utf-8",
    // url: "/api/stw",
    url: "http://apitesting.domain.com/api/stw,",
    data: "{}",
    dataType: "json",
    success: function (data) {
    console.log(data);
    // var myData = JSON.parse(data)
    for (var i = 0; i < data.length; i++) {
    $("#tbDetails").append("" + data[i].Name + "" + data[i].loan + "" + data[i].evnt + "");
    }
    },
    error: function (result) {
    alert("Error");
    }
    });
    });

    I am currently hosting my cross domain web api on the above url. I have added the custom headers in the web.config file of my web api. I have also added ‘enabled.cors’ property in my stwAPIController. I tried parsing the data in ajax through the following method ‘JSON.parse(data)’,but I am still getting the same error, as mentioned above.

    [EnableCors(origins: "http://apitesting.domain.com/api/stw", headers: "*", methods: "*")]
    public class STWController : ApiController
    {
    private cdwEntities db = new cdwEntities();

        public IEnumerable getData()
        {
    
            var data = db.Database\_CRE\_LoanEvents.Where(c => c.Date.Contains("2015") && c.Loan\_property != null)
                          .Select(x => new Loan() { Name = x.Deal, loan = x.Loan\_property, evnt = x.Event })
                          .ToList().Take(3);
            return data;
        }
    }
    

    Any further help, would be very much appreciated.

    ASP.NET json database help com hosting

  • how to improve nested linq query
    M miss786

    I would like to be able to call string tag1 & tag2 with multiple values, such as Api/test?tag1=123,456,789&tag2=987,654 However, the below contain function only allows me to call 45 values for each tag1 & tag2, anything more than 45 string values used to search tag1 & tag2, the code throws a nested query error: "$id":"1","Message":"An error has occurred.","ExceptionMessage":"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries. I tried adding toList() to my tag1 method, but I keep getting syntax error: Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?) any further advice, would be very much appreciated. Thank you.

    IQueryable Data = null;

                if (!string.IsNullOrEmpty(query.tag2))
                {                  
                    var ids = query.tag2.Split(',');
    
                    var dataMatchingTags = db.database\_BCs.Where(c => ids.Contains(c.TAG2));
    
                    if (Data == null)
                        Data = dataMatchingTags;
                    else
                        Data = Data.Union(dataMatchingTags);
                }
    
                if (!string.IsNullOrEmpty(query.tag1))
                {
                    var ids = query.tag1.Split(',');
    
                    var dataMatchingTags = db.database\_BCs.Where(c => ids.Contains(c.TAG1));
    
                    if (Data == null)
                        Data = dataMatchingTags;
                    else
                        **Data = Data.Union(dataMatchingTags).ToList();**
                }
    
                if (Data == null) // If no tags is being queried, apply filters to the whole set of products
                    Data = db.database\_BCs;
    
                if (query.dl\_type != null)
                {
                    Data = Data.Where(c => c.Type == query.dl\_type);
                }
    			
    	  **var data = Data.ToList();**
    
                if (!data.Any())
                {
                    var message = string.Format("No data found");
                    return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
                }
    
    ASP.NET database linq csharp json help

  • SQL Replace Function - error recognizing two or more strings
    M miss786

    Thank you for your suggestion and help. I am manage to get the cursor function work by adding a distinct clause in the tags select query of function:

    DECLARE @fullame VARCHAR(MAX)
    DECLARE CUR CURSOR FAST_FORWARD FOR
    SELECT distinct name
    FROM database_tags
    Where UploadDate >= '2014-09-01'

    Thank you very much Richard for your solution, I am sorry to inform, the above solution was little slow loading the articles with hyperlinks name, hence I choose the cursor function approach. Thank you all, for your time and suggestion for this post. I appreciate all your help.

    Database database help xml tutorial

  • SQL Replace Function - error recognizing two or more strings
    M miss786

    Thank you very much for your reply and help. I have already tried the above approach and unfortunately, it gives me incorrect output. I pass the following XML Input to the UDF:

    <Body>

    One is a 1m block of AIREM 2006-1X 2A3, which has never appeared on SMO.

    </Body>

    the function above, outputs the following (which is incorrect).

    One is a £1m block of [AIREM 2006-1X 2A3](<a href=)">[AIREM 2006-1X 2A3](<a href=)">[AIREM 2006-1X 2A3](<a href=)">[AIREM 2006-1X 2A3](<a href=)

    The desired output should be :

    <Body>

    One is a 1m block of [AIREM 2006-1X 2A3](pagename.aspx?tag=AIREM 2006-1X 2A3), which has never appeared on SMO.

    </Body>

    I have attached an example of my dataset in the following link below, for further reference as to what my dataset types are. http://sqlfiddle.com/#!6/96cac8/2 I looked into a cursor approach for this replace function and have come up with the following below. However, I am still experiencing the same output error, as explained above. the function loops through continuously and creates duplicate names of hyperlinks, within the XML data.

    ALTER FUNCTION [dbo].[ReplaceTags2](@XML VARCHAR(MAX))
    RETURNS VARCHAR(MAX)
    AS
    BEGIN

    DECLARE @Name VARCHAR(MAX)
    DECLARE CUR CURSOR FAST_FORWARD FOR
    SELECT name
    FROM [dbo].[database_tags]
    Where UploadDate >= '2014-09-01'
    and @XML LIKE '%' + Name + '%'

    OPEN CUR

    WHILE 1 = 1
    BEGIN
    FETCH cur INTO @name
    --IF @Name IS NOT NULL
    IF @@fetch_status <> 0
    BREAK
    BEGIN
    SELECT @XML = REPLACE(@XML,
    @Name,
    '['+@Name+'](<a href=)')
    END
    --FETCH NEXT FROM CUR INTO @Name
    END

    CLOSE CUR;
    DEALLOCATE CUR;

    RETURN @XML
    END

    Please advice further, if possible. Thank you for your help and time.

    Database database help xml tutorial

  • SQL Replace Function - error recognizing two or more strings
    M miss786

    I am trying to replace names found in 'xml' fieldname as hyperlinks, by matching with the names in database_tags. I am using the following function below, however the UDF is only recognizing one name from the XML fieldname data, instead of all the names present in the XML data.

    ALTER FUNCTION [dbo].[ReplaceTags](@XML VARCHAR(MAX))
    RETURNS VARCHAR(MAX)
    AS
    BEGIN

    DECLARE @N VARCHAR(MAX)
    SELECT @N = [Name] FROM [dbo].[database_tags]
    WHERE @XML LIKE '%'+[Name]+'%'
    AND UploadDate >= '2014-09-01'

    IF @N IS NOT NULL
    BEGIN
    SELECT @XML = REPLACE(@XML,
    @N,
    '['+@N+'](<a href=)')
    END
    RETURN @XML
    END

    for example, if the XML input data is the following: It consists of: BANKP, BCJA, BCJAM, BFTH, BFTH, and EMPOP. But the updated function is only recognizing two of names BFTH, BFTH, as hyperlinks, from the database_tags table. Is there a way to get the function to recognize more than one names as hyperlinks. Thank you very much for your time and help.

    Database database help xml tutorial

  • SignalR - Jquery response - 304 error
    M miss786

    Dear all, I am running the following script on the client-side and the script is failing to update, when there is change in the database. I debugged the script using web-browser debugger and discovered my Jquery scripts are responding back as "304 not modified". I am assuming the server code is sending 304 resp. if so, what tests can I carry out, to help me debug server code, to find where the logic maybe going wrong. Client-side:

    <script src="../Scripts/jquery-1.6.4.js"></script>
    <script src="../Scripts/jquery.signalR-2.1.2.min.js"></script>
    <script src='<%: ResolveClientUrl("~/signalr/hubs") %>'></script>
    <script type="text/javascript">
    $(function () {
    // Declare a proxy to reference the hub.
    var notifications = $.connection.NotificationHub;
    // Create a function that the hub can call to broadcast messages.
    notifications.client.recieveNotification = function (role, descrip) {
    // Add the message to the page.
    $('#spanNewMessages').text(role);
    $('#spanNewCircles').text(descrip);
    };
    // Start the connection.
    $.connection.hub.start().done(function () {
    notifications.server.sendNotifications();
    alert("Notifications have been sent.");

    }).fail(function (e) {
        alert(e);
    });
    //$.connection.hub.start();
    

    });
    </script>

    New Notifications

    New = role.
    New = descrip.

    The server side code is created signalR hub class and also has sql dependency logic as well:

    [HubName("NotificationHub")]
    public class notificationHub : Hub
    {
    string role = "";
    string descrip = "";

    \[HubMethodName("sendNotifications")\]
    public void SendNotifications()
    {
        using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings\["##########"\].ConnectionString))
        {
    
            string query = "SELECT top 1 \[role\],\[description\] FROM \[dbo\].\[User\] order by uploadDate desc";
            connection.Open();
            SqlDependency.Start(GetConnectionString());
    
            using (SqlCommand command = new SqlCommand(query, connection))
            {
    
                try
                {
                    command.Notification = null;
                    DataTable dt = new DataTable();
                    SqlDepe
    
    ASP.NET javascript database debugging help sysadmin

  • How to verify email address using mx record?
    M miss786

    Thank you very much for your reply. Apology for the late response. When I tested the IsValidEmailDomain method, for my domain, it showed up as false. I tried adding in the try...catch block, but I am still getting a false domain address (####.com) and I have also tried testing it using my personal domain address (####@gmail.com), which also results in false. I have tried compiling many variations of the test method, to catch the error within the IsValidEmailDomain, but I keep experiencing false/null for each of the domain address.

        public static bool IsValidEmailDomain(MailAddress address)
        {
            if (address == null) return false;
            var response = DnsClient.Default.Resolve(address.Host, RecordType.Mx);
            try
            {
                if (response == null || response.AnswerRecords == null) return false;
            }
            catch (FormatException)
            {
                return false;
            }
    
            return response.AnswerRecords.OfType().Any();
        }
    
     public static string test()
        {
            string mail = "#####6@gmail.com";
            bool? answer = null;
            Exception ex;
            try
            {
                answer = IsValidEmailDomain(mail);
            }
            catch (Exception e)
            {
                ex = e;
            }
            if (answer.HasValue)
            {
                return answer.ToString();
            }
            else
            {
                return null;
                // catch exception
            }
        }
    

    However, when I test the following domain address (###.com) with my original mx() method, it displays a mx-record (mail.###.com) for my domain address. I have also tested my mx() method using my gmail address and it outputs an mx-record for it.

     public static string mailMX()
        {
            string domainName = "#######.com";
            string mail = "";
    
            var response = DnsClient.Default.Resolve(domainName, RecordType.Mx);
            var records = response.AnswerRecords.OfType();
           foreach (var record in records)
            {
               return (record.ExchangeDomainName).ToString();
            }
    
           return mail = records.ToString();
        }
    

    I am trying to send email via XML to 3rd party client via web request and in order to send the e

    ASP.NET question com help tutorial

  • How to verify email address using mx record?
    M miss786

    I am writing to seek help, in regards to figuring out, how can I verify my email address using mx record. I am currently new into using MX records and so far, I have method which returns a mx record for specific domain (as shown below):

    public static string mailMX()
    {
    string domainName = "#######.com";
    string mail = "";

        var response = DnsClient.Default.Resolve(domainName , RecordType.Mx);
        var records = response.AnswerRecords.OfType();
        foreach (var record in records)
        {
           return (record.ExchangeDomainName).ToString();
        }
    
        return mail = records.ToString();
    
    }
    

    My desire goal is to create a method, which can verify the email address "info@reply.####.com" has a valid mx record and return the email address. I am slightly struggling in this area, as I am not to sure how to structure this task. Any hints would be most appreciated. Thank you

    ASP.NET question com help tutorial

  • How to return GetResponseStream in xml?
    M miss786

    I am trying to create web request, which sends XML via POST call and would like to return the response back in XML. I am having a little difficulty with the response back xml, as I am little I unsure how do I set that up int he code below. here is my attempt:

     // Attempt to receive the WebResponse to the WebRequest.
            using (HttpWebResponse hwresponse = (HttpWebResponse)hwrequest.GetResponse())
            {
                statusCode = (int)hwresponse.StatusCode;
                if (hwresponse != null)
                { // If we have valid WebResponse then read it.
                    using (StreamReader reader = new StreamReader(hwresponse.GetResponseStream()))
                    {
                        // XPathDocument doc = new XPathDocument(reader);
                        string responseString = reader.ReadToEnd();
                        if (statusCode == 201 )
                        {
    
                          //  var response = new XElement("Status",
                           //    new XElement("status\_code", statusCode),
                          //     new XElement("resources\_created",
                          ////         new XElement("Link"),
                          //         new XElement("href"),
                          //         new XElement("title")
                          //         ),
    
                          //         new XElement("warnings")
    
                           //        );
    
                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.Load(responseString);
                            XmlNodeList address = xmlDoc.GetElementsByTagName("Status");
    
                            responseData = xmlDoc.ToString();
                            reader.Close();
    
                        }
                    }
                }
    
                hwresponse.Close();
    
            }
    
        }
        catch (WebException e)
        {
            if (e.Status == WebExceptionStatus.ProtocolError)
            {
               // XmlDocument xmlDoc = new XmlDocument();
              //  XmlNodeList address = xmlDoc.GetElementsByTagName("Status", statusCode);
               // xmlDoc.Load(xmlDoc);
            }
    
    
    
         //   if (e.Status == WebExceptionStatus.ProtocolError)
         //   {
              //  responseData = "Status Code : {0}" + ((HttpWebResponse)e.Response).StatusCode + "Status Description : {0}" + ((HttpWebResponse)e.Response).StatusDescription;
    
    ASP.NET question xml tutorial

  • create a xml child node
    M miss786

    Dear all, With my current code, I am getting output as shown in output1:

    string autoDate = uriBuilder.activateMethod();
            XElement xeRoot = new XElement("mailjob");
    
            XElement xeSendDate = new XElement("send\_datetime", autoDate);
            xeRoot.Add(xeSendDate);
    
            XElement xeStatus = new XElement("subject", "Draft");
            xeRoot.Add(xeStatus);
    
            XElement xeDisplayDate = new XElement("from\_name", "MCI");
            xeRoot.Add(xeDisplayDate);
    
            XElement xeFormat = new XElement("format", "HTML");
            xeRoot.Add(xeFormat);
    
            XElement xeSendTo = new XElement("to");
            xeSendTo.Add(new XAttribute("target\_type", "###"));
            xeSendTo.Add(new XAttribute("targets", "####"));
            xeRoot.Add(xeSendTo);
    
            XDocument xDoc = new XDocument(xeRoot);
            return xDoc.ToString();
    

    output1:

    		12-09-2014 15:20:31 
    		Draft 
    		MCI 
    		<format>HTML</format>  
    

    However, I would create sub child for node, such as shown below:

    		12-09-2014 15:20:31 
    		Draft 
    		MCI 
    		<format>HTML</format> 
    		
    		####
    		#####
    

    How can I achieve this? Please advice further. Thanks

    ASP.NET question html xml

  • How to create page filter parameter in web api?
    M miss786

    I am writing to seek help in, how can I add page filter parameter to my method below, which can allow me to call a query string such as -- api/feed?name=st&page=2. I have tried using the page size property to make this work but the output would always give me 'no data response'. This is what I currently have and I am little stuck in how can I make this work. Please advice. Any solution would be most helpful. Many thanks.

    public HttpResponseMessage get([FromUri] Query query )
    {
    int pageSize = 10;
    int page = 0;

            IQueryable Data = null;
    
            if (!string.IsNullOrEmpty(query.name))
            {
                var ids = query.name.Split(',');
    
                var dataMatchingTags = db.data\_qy.Where(c => ids.Any(id => c.Name.Contains(id)));
    
                if (Data == null)
                    Data = dataMatchingTags;
                else
                    Data = Data.Union(dataMatchingTags);
            }
    
            if (Data == null) 
                Data = db.data\_qy;
    
            if (query.endDate != null)
            {
                Data = Data.Where(c => c.UploadDate <= query.endDate);
            }
    
            if (query.startDate != null)
            {
                Data = Data.Where(c => c.UploadDate >= query.startDate);
            }
    
            var totalCount = Data.Count();
           // var totalPages = (int)Math.Ceiling((double)totalCount / pageSize);
    
           // var urlHelper = new UrlHelper(Request);
           // var prevLink = page > 0 ? urlHelper.Link("DefaultApi", new { page = page - 1 }) : "";
           // var nextLink = page < totalPages - 1 ? urlHelper.Link("DefaultApi", new { page = page + 1 }) : "";
    
            Data = Data.OrderByDescending(c => c.UploadDate);
    
            var data = Data.Skip(pageSize \* page).Take(pageSize).ToList();
    
            if (!data.Any())
            {
                var message = string.Format("No data found");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
            }
    
            //return Request.CreateResponse(HttpStatusCode.OK, data);
            //return Request.CreateResponse(HttpStatusCode.OK, new { totalCount, totalPages, prevLink, nextLink, data });
            return Request.CreateResponse(HttpStatusCode.OK, new { totalCount, data });
        }
    
    ASP.NET database help question linq json

  • How to test post method in fiddler - web api
    M miss786

    I am trying to test my post method using fiddler as below: In the [Composor] tab, I am calling the following url [http://localhost:45361/api/test\], in the [Parse] tab using method type as [POST]. In the [Request Header], I have [User-Agent: Fiddler, Content-Type: application/json; charset=utf-8] and in [Request Body], I am filtering: { "name":"storm" } However, the above post request, returns the entire dataset instead of records with name = storm. I have tried changing the method to [FromBody], which causes reference error in the code: Object reference not set to an instance of an object

    [HttpPost]
    public HttpResponseMessage post([FromBody] Query query)
    {
    IQueryable Data = null;

                if (!string.IsNullOrEmpty(query.tag))
                {
                    var ids = query.tag.Split(',');
                    var dataMatchingTags = db.data\_qy.Where(c => ids.Contains(c.TAG));
    
                    if (Data == null)
                        Data = dataMatchingTags;
                    else
                        Data = Data.Union(dataMatchingTags);
                }
    
                if (!string.IsNullOrEmpty(query.name))
                {
                    var ids = query.name.Split(',');
                    var dataMatchingTags = db.data\_qy.Where(c => ids.Any(id => c.Name.Contains(id)));
    
                    if (Data == null)
                        Data = dataMatchingTags;
                    else
                        Data = Data.Union(dataMatchingTags);
                }
    
                if (Data == null) // If no tags or name is being queried, apply filters to the whole set of products
                    Data = db.data\_qy;
    
                if (query.endDate != null)
                {
                    Data = Data.Where(c => c.UploadDate <= query.endDate);
                }
    
                if (query.startDate != null)
                {
                    Data = Data.Where(c => c.UploadDate >= query.startDate);
                }
    
                var data = Data.ToList();
    
                if (!data.Any())
                {
                    var message = string.Format("No data found");
                    return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
                }
    
                return Request.CreateResponse(HttpStatusCode.OK, data);
            }
    

    please advice, if I am missing something or my approach to te

    ASP.NET database json linq agentic-ai help

  • Displaying data from database using javascript.
    M miss786

    Thank you for your response. I would like to be able to call (getData) query when the page loads and show the (getData) query results in a(using 'line method' -- see javascript code) line chart. When I use the data filters in javascript(categoryPicker), I would like to control filters (categoryPicker), to use (getData2) method query to filter the line charts' output. for example: when page loads, call query1(select top 100 * from data), then click/mouseover/search on filter(categoryPicker), filter the line chart results using qyery2(select * from data). I hope the explanation above clarifies my problem. Any help would be very much appreciated. Thank you for your time and help.

    JavaScript csharp javascript database tools tutorial

  • Displaying data from database using javascript.
    M miss786

    Hi, I would like the javascript to show data from getData method (webMethod), when the page loads but when filter the data (categoryPicker control), using webMethod getData2. This is currently my c# page.

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {

            JavaScriptSerializer jss = new JavaScriptSerializer();
            ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript",
                //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>",
           string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>",
            jss.Serialize(GetData()),
        "Name Example",
        "Name",
        "Type Example",
        "Type Example",
         "Type,"));
    
        }
            else 
    
            {
                JavaScriptSerializer jtt = new JavaScriptSerializer();
        ClientScript.RegisterStartupScript(this.GetType(), "TestInitPageScript",
            //string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){'drawVisualization'({0},'{1}','{2}');});</script>",
       string.Format("<script type=\\"text/javascript\\">google.load('visualization','1.0',{{'packages':\['corechart','controls'\]}});google.setOnLoadCallback(function(){{drawVisualization({0},'{1}','{2}','{3}');}});</script>",
        jtt.Serialize(GetData2()),
    "Name Example",
    "Name",
    "Type Example",
    "Type Example",
     "Type,"));
    
            }
        }
    
        
    
    
    
    \[WebMethod\]
    public static List GetData()
    {
        SqlConnection conn = new SqlConnection("#####");
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        conn.Open();
        var yesterday = DateTime.Today.AddDays(-1);
        string cmdstr = "select top 500 Name, \[Decimal price\],Cover, UploadDate from \[dbo\].\[database\] order by UploadDate desc";
        SqlCommand cmd = new SqlCommand(cmdstr, conn);
        //cmd.Parameters.AddWithValue("@value", yesterday);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);
    
    JavaScript csharp javascript database tools tutorial

  • Date formatting - Charts
    M miss786

    Apology for the late response. Thank you very much for your feedback. I manage to get the date value pass the parseInt but however, now I am getting a blank screen on the client-end, with the following warning in the console debug of my chrome browser: event.returnValue is deprecated. Please use the standard event.preventDefault() instead. --> warning

        function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption) {
            if (dataValues.length < 1)
                return;
    
            var data = new google.visualization.DataTable();
            data.addColumn('string', columnNames.split(',')\[0\]);
            data.addColumn('number', columnNames.split(',')\[1\]);
            data.addColumn('string', columnNames.split(',')\[2\]);
            data.addColumn('datetime', columnNames.split(',')\[3\]);
    
            for (var i = 0; i < dataValues.length; i++) {
    
                //var date = new Date(parseInt(dataValues\[i\].Date.substr(6), 10));
                var date = new Date(parseInt(dt.getValue(row, 3)));
    
                data.addRow(\[dataValues\[i\].ColumnName, dataValues\[i\].Value, dataValues\[i\].Type, date\]);
            }
    
            // Define a category picker control for the Gender column
            var categoryPicker = new google.visualization.ControlWrapper({
                'controlType': 'CategoryFilter',
                'containerId': 'CategoryPickerContainer',
                'options': {
                    'filterColumnLabel': columnNames.split(',')\[2\],
                    'filterColumnIndex': '2',
    
                    'ui': {
                        'labelStacking': 'horizontal',
                        'allowTyping': false,
                        'allowMultiple': false,
                        'caption': categoryCaption,
                        'label': 'Price Type',
                    }
                }
            });
    
            var dateFormatter = new google.visualization.DateFormat({ pattern: 'dd MM yyyy' });
            var line = new google.visualization.ChartWrapper({
                'chartType': 'LineChart',
                'containerId': 'PieChartContainer',
                'options': {
                    'width': 950,
                    'height': 450,
                    'legend': 'right',
                    'hAxis': {
                        'format': "dd-MM-yyyy",
                        'hAxis.maxValue': 'viewWindow.max',
                        'maxV</x-turndown>
    
    JavaScript help regex

  • Date formatting - Charts
    M miss786

    I am having a little issue, with getting dates to show up in desired (dd-mm-yyyy) format, however they are displayed as 'NaN Nan' on the line chart x-axis. I have added in a 'parseInt' date format but I am not sure if this is a correct approach. Please advice. Many thanks for your help and time.

    function drawVisualization(dataValues, chartTitle, columnNames, categoryCaption) {
        if (dataValues.length < 1)
            return;
    
        var data = new google.visualization.DataTable();
        data.addColumn('string', columnNames.split(',')\[0\]);
        data.addColumn('number', columnNames.split(',')\[1\]);
        data.addColumn('string', columnNames.split(',')\[2\]);
        data.addColumn('datetime', columnNames.split(',')\[3\]);
    
        for (var i = 0; i < dataValues.length; i++) {
    
            var date = new Date(parseInt(dataValues\[i\].Date.substr(6), 10));
    
            data.addRow(\[dataValues\[i\].ColumnName, dataValues\[i\].Value, dataValues\[i\].Type, date\]);
        }
    
        var dateFormatter = new google.visualization.DateFormat({ pattern: 'dd MM yyyy' });
        var line = new google.visualization.ChartWrapper({
            'chartType': 'LineChart',
            'containerId': 'PieChartContainer',
            'options': {
                'width': 950,
                'height': 450,
                'legend': 'right',
                'hAxis': {
                    'format': "dd-MM-yyyy",
                    'hAxis.maxValue': 'viewWindow.max',
                    'maxValue': new Date(2014, 05, 30), 'minValue': new Date(2014, 04, 05),
                    'viewWindow': { 'max': new Date(2014, 05, 30) },
                },
                'title': chartTitle,
                'chartArea': { 'left': 100, 'top': 100, 'right': 0, 'bottom': 100 },
                'tooltip': { isHtml: true }
            },
            'view': {
                'columns': \[{
    
                    type: 'string',
                    label: data.getColumnLabel(3),
                    calc: function (dt, row) {
                        var date = new Date(parseInt(dt.getValue(row, 3)));
                        return dateFormatter.formatValue(date);
                    }
                }, 1, {
                    type: 'string',
                    role: 'tooltip',
                    calc: function (dt, row) {
                        return 'Name: ' + dt.getValue(row, 0) + ', Decimal Price: ' + +dt.getValue(row, 1) + ', Date: ' + +dt.getFormattedValue(row, 3);
    
    JavaScript help regex

  • How to assign claim identity role to user queries
    M miss786

    Dear all, I am writing to seek help, what is the process of creating a claim identity model, to assign role/name to queries. the queries below, output to sets of users and I would like to know, how can I assign role/name to them using claim identity, if possible.

    public UserDetail trial_test(string username, string password)
    {

           var query = from s in db.Subscriptions
                            join u in db.UserDetails on s.sUID equals u.uID
                            where s.s\_ExpiryDate >= DateTime.Now &&
                            s.sPID.Value == 163 &&
                            s.sAll.Value != true &&
                            u.uUsername == username &&
                            u.uPassword == password
                            select u; 
                return query.FirstOrDefault(); 
            }
            
        
        public UserDetail full\_test(string username, string password)
            {
                var query = from s in db.Subscriptions
                            join u in db.UserDetails on s.sUID equals u.uID
                            where s.s\_ExpiryDate >= DateTime.Now &&
                            s.sPID.Value == 163 &&
                            s.sAll.Value == true &&
                            u.uUsername == username &&
                            u.uPassword == password
                            select u;
                return query.FirstOrDefault();
            }
    

    Thanks in advance.

    ASP.NET database question help tutorial

  • Null linq query issue - web api
    M miss786

    Dear all, I am having a little issue with calling couple of queries from my filter method and would like to seek some a guidance to what I may doing wrong. if I call (api/test?tag=##,##,...), the query works fine. However, if I do not use the line of code -- var data2 = db.data_qy.AsQueryable(); and I call ((api/test?price_type=BVR), the query works and result is shown, otherwise if I do not use that line of code, i get a error -- ExceptionMessage":"Value cannot be null Also, If I use var data2 = db.data_qy.AsQueryable(); and call query ((api/test?price_type=BVR&deal_type=TYP), the query outputs entire dataset, instead filtering result to the search query. Please help. Many thanks

    public HttpResponseMessage get([FromUri] Query query)
    {
    IQueryable data = null;

            if (!string.IsNullOrEmpty(query.tag))
            {
                var ids = query.tag.Split(',');
    
                var dataMatchingTags = db.data\_qy.Where(c => ids.Any(id => c.TAG.Contains(id)));
    
                if (data == null)
                    data = dataMatchingTags;
                else
                    data = data.Union(dataMatchingTags);
            }
    
            var data2 = db.data\_qy.AsQueryable();
    
            if (query.deal\_type != null)
            {
                data = data2.Where(c => c.Type == query.deal\_type);
            }
    
            if (query.price\_type != null)
            {
                data = data2.Where(c => c.Cover == query.price\_type);
            }
    
            var materializedData = data.ToList();
    
            if (!materializedData.Any())
            {
                var message = string.Format("No data found");
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
            }
            return Request.CreateResponse(HttpStatusCode.OK, materializedData);
        }
    
    ASP.NET help database linq csharp json

  • filterData linq query - EntityCommandExeceptionException error
    M miss786

    I have tried changing how the filterdata is added to the list, but I am still experiencing the same issue as my orginal post:

    if (!string.IsNullOrEmpty(query.name))
            {
                var ids = query.name.Split(',');
                foreach (string i in ids)
                {
                    **var list = data.Where(c => c.Name != null && c.Name.Contains(i)).AsQueryable();
                    filteredData.Add(list);**
                }
            }
    

    could someone please provide any assistance. Many thanks.

    ASP.NET database help csharp linq regex

  • filterData linq query - EntityCommandExeceptionException error
    M miss786

    Dear all, When I try to query 24 values of name parameter , api/test/name=stop,tap,app...(24 names values), I get a following EntityCommandExeceptionException error as an output response: "Message":"An error has occurred.","ExceptionMessage":"Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.","ExceptionType":"System.Data.SqlClient.SqlException

    public HttpResponseMessage get([FromUri] Query query)
    {
    var data = db.database_bd.AsQueryable();

                if (query.startDate != null)
                {
                    data = data.Where(c => c.UploadDate >= query.startDate);
                }
    
                // If any other filters are specified, return records which match any of them:
                var filteredData = new List\>();
    
                if (!string.IsNullOrEmpty(query.name))
                {
                    var ids = query.name.Split(',');
                    foreach (string i in ids)
                    {
                        filteredData.Add(data.Where(c => c.Name != null && c.Name.Contains(i)));
                    }
                }
                // If no filters passed, return all data.
                // Otherwise, combine the individual filters using the Union method
                // to return all records which match at least one filter.
                if (filteredData.Count != 0)
                {
                    data = filteredData.Aggregate(Queryable.Union);
                }
                ****if (!data.Any())** //line causing the error**
                {
                    var message = string.Format("No data was found");
                    return Request.CreateErrorResponse(HttpStatusCode.NotFound, message);
                }
    
                return Request.CreateResponse(HttpStatusCode.OK, data);
            }      
    }
    

    Do I have to assign count value to filterdata, or Is their certain threshold, to search criteria, if using the split function? Any help would be very much appreciated. Thanks in advance.

    ASP.NET database help csharp linq regex
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups