|
All your code does is call SQL. So, no, the problem is not in the code. You'll have to debug your sql to find out why it is slow.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
This may be too late, but …
Try this:
1) Move the Dim dt as New DataTable() before the Using sda statement
2) Move the gvCustomers.DataSouce and Databind statement after the end Using
3) Leave the sda.Fill(dt) inside the Using … end Using block
My theory is that the databinding is taking too long and subsequently the SQL fails because everything is wrapped inside the Using … end Using block.
Just a theory. Give it a shot and post back your results.
|
|
|
|
|
Hi all,
Im looking for information but I dont know if there is a special phase or term to describe it.
Basically, I am building a little Ticketing/Helpdesk system. I do not want to hard code the Questions/Forms. I want an admin to be able to create a Questions/FOrms under a specific Subject.
What should i be searching for to find information on this?
Thanks
Chris
Chris Wright
|
|
|
|
|
This is more a design issue.
You need to store the questions somewhere, usually a database.
You then need to create a form so the admin can create the the questions, storing them in your data store.
You then need to collect the responses for each question and store them in your data store.
After that you have to create the workflow that will support your business requirement.
All of the above can be achieved with winforms and a database. I would probably search for survey or help desk or bug tracking examples.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Thank you for the reply. It gives me an idea of how the stucture needs to be. I need to make sure I get the database right. It's going to be very complex.
Im going to struggle figuring how to separate the data into tables and then link it all back together to display it within the front end.
Chris Wright
|
|
|
|
|
Take a look at http://www.databaseanswers.org/data_models/[^] and see if there is one that meets your needs. It is a good site to study the structures of databases.
And yes put lot of effort into designing your data structure, think through your requirements before you start creating your database.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
In the first DropdownList should display the Countries and in the second should display Cities based on the Country like .. USA then display just cities in USA . well i am getting undefined in dropdown city the Question is why i am getting always undefined in City dropDown list ?
here is countrol :
<pre> public ActionResult Index()
{
Details();
return View();
}
public void Details (
{
var model = db.GetUniversities().ToList();
List<SelectListItem> li = new List<SelectListItem>();
li.Add(new SelectListItem { Text = "Please select Country",Value="0"});
foreach (var item in model)
{
li.Add(new SelectListItem { Text = item.Country, Value = item.Id.ToString()});
ViewBag.state = li;
}
}
[HttpPost]
public JsonResult GetCity (int id)
{
var ddlCity = db.GetUniversities().Where(x => x.Id == id).ToList();
List<SelectListItem> licities = new List<SelectListItem>();
if (ddlCity != null)
{
foreach (var x in ddlCity)
{
licities.Add(new SelectListItem { Text = x.City, Value = x.Id.ToString() });
}
}
return Json(new SelectList(licities, "Text", "Value"));
}
here view
<div class="form-group">
@Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>, new { style = "width: 200px;" })
@Html.ValidationMessageFor(model => model.Country, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.City, new SelectList(string.Empty, "Value", "Text"), "--Select City--", new { style = "width:200px" })
@Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })
here jQuery
$(document).ready(function () {
$("#Country").change(function () {
$("#City").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetCity")',
dataType: 'json',
data: { id: $("#Country").val() },
success: function (city) {
$.each(city, function (i, city) {
$("#City").append('<option value="' + city.Value + '">'+ city.Text + '</option>');
});
},
error: function (ex) {
alert('Failed.' + ex);
}
});
return false;
})
});
|
|
|
|
|
You may have to set an ID attribute to your DropDownListFor control so you can reference them in your jQuery code. For example:
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>, { @id="ddlCountry", @class="YourCSSClassName" })
then in your jQuery, you can access it like this:
$("#ddlCountry").change(function () {
});
|
|
|
|
|
i am still getting the same error .. where should i exactly write the id .. could you more explain please
i thank you very much in advanced
|
|
|
|
|
You need to give ID's to all your controls that you reference in your jQuery and then use the IDs just like what I demonstrated. If you followed that and you are still getting error, then post your updated code here and show us which line you are getting the error.
|
|
|
|
|
Hi Vincent,
so i am still getting the same problem thus let me show you what i have changed .
i did what you have told me . could you check once again and in SQL there are some Countries and Cities like USA -> Bosten , Germany -> Frankfurt etc....
the View :
<div class="form-group">
@Html.LabelFor(model => model.Country, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.Country, ViewBag.state as List<SelectListItem>
, new {@id ="ddlCountry", @class = "form-control" })
<div class="form-group">
@Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.City, new SelectList(string.Empty, "Value", "Text"), "--Select City--",
new {@id ="ddlCity", @class = "form-control" })
The jQuery :
$(document).ready(function () {
$("#ddlCountry").change(function () {
$("#ddlCity").empty();
$.ajax({
type: 'POST',
url: '@Url.Action("GetCity")',
dataType: 'json',
data: { id: $("#ddlCountry").val() },
success: function (city) {
$.each(city, function (i, city) {
$("#ddlCity").append('<option value="' + city.Value + '">'+ city.Text + '</option>');
});
},
error: function (ex) {
alert('Failed.' + ex);
}
});
return false;
})
});
and with Controls haven't changed :
public void Details ()
{
var model = db.GetUniversities().ToList();
List<SelectListItem> li = new List<SelectListItem>();
li.Add(new SelectListItem { Text = "Please select Country",Value="0"});
foreach (var item in model)
{
li.Add(new SelectListItem { Text = item.Country, Value = item.Id.ToString()});
ViewBag.state = li;
}
}
[HttpPost]
public JsonResult GetCity (int id)
{
var ddlCity = db.GetUniversities().Where(x => x.Id == id).ToList();
List<SelectListItem> licities = new List<SelectListItem>();
licities.Add(new SelectListItem { Text = "--Select City--", Value = "0" });
if (ddlCity != null)
{
foreach (var x in ddlCity)
{
licities.Add(new SelectListItem { Text = x.City, Value = x.Id.ToString() });
}
}
return Json(new SelectList(licities, "Text", "Value"));
|
|
|
|
|
What error are you getting now? Still undefined? Please be specific also for the errors that you are currently getting.
|
|
|
|
|
it's fine now . i have got it .
i thank you a lot
|
|
|
|
|
That's great! Glad to be of help!
|
|
|
|
|
Hello,
This issue occurs when a request process with "&" char (URL With "&").
e.g.
http://PSL.com/CALCC&test&Calendar2018_AR.pdf
Our requirement is to allow URL With "&" request using HTTP modules in IIS.
We don't want to modify web.config file for resolving this issue.
Means validation request=false in web.config. We need to solve this issue using HTTP module.
Need your suggestion on this issue.
Thanks,
Yuvraj
|
|
|
|
|
|
Thanks for replay. Please suggest for handle this issue using HTTP Module class.
|
|
|
|
|
Hello;
I have 2 different class libraries (data model, business services) in my solution. There is an app config file in the data model. I wonder if I can read it inside of business services? (the error is configuration manager does not exist.)
I can add values into web config which is in the web API project in this solution but this time I need to add web API project in the reference of business services. It gives a circular dependency error.
|
|
|
|
|
It depends what is hosting the code. If the code is running under IIS then you need the values in the web.config, if the code is running inside an EXE then the values need to be in a "processname.exe.config" file.
|
|
|
|
|
Greetings again,
I am still having some issues with this project.
This time, the issue is with pulling records by passing date values.
Everything else seems to work well.
We have two date parameters, date_start and date_end
A user can enter just value for start date only, end date only or date range between start date and end date.
The issue is that if a user enters start date, and clicks search, we get No data found message.
If user enters either value for end date or date range between start date and end date, the system hangs.
On the DB, using SSMS, if I enter a value for start date, I get results.
Similarly, if I enter value for either end date or date range between start date and end date, I get results very quickly.
When I put a debugger on my asp.net code, it returns the exact same value as the value I get when I run it from SSMS.
For instance,
Here is a value for start and end dates:
start date: 2014-05-05 10:34:03
end date: 2014-05-05 10:35:52
These values are the same when I query from the DB and as well as when I put debugger on my code.
The data type for these dates is DateTime2(0).
Any ideas why this is not working from my app?
Here are some code snips:
'//stored proc WHERE clause
WHERE 1 = 1
AND ((@uuid IS NULL OR qp.uuid Like '%' + @uuid + '%')
AND (@callerlist IS NULL OR qp.call_list_id Like '%' + @callerlist + '%')
AND (@phone IS NULL OR cl.phone_number Like '%' + @phone + '%')
AND (@start IS NULL OR startttime >= @start)
AND (@Endd IS NULL OR endtime <= @Endd)
AND (@calltype IS NULL OR c.id Like '%' + @calltype + '%')
AND cl.phone_number IS NOT NULL)
'/
<asp:TextBox id="date_start" style="width:150px;" class="form-control alignleft" runat="server" />
<asp:TextBox id="date_end" style="width:150px;" class="form-control alignleft" runat="server" />
'/VB:
Private Sub SearchCustomers()
Dim constr As String = ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand()
Dim sql As String = "spGetLogs"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@uuid", suuid.Text)
cmd.Parameters.AddWithValue("@callerlist", caller_list_id.Text)
cmd.Parameters.AddWithValue("@phone", phonenumber.Text)
cmd.Parameters.AddWithValue("@start", date_start.Text)
cmd.Parameters.AddWithValue("@Endd", date_end.Text)
cmd.Parameters.AddWithValue("@calltype", call_type.SelectedValue)
'Response.Write(sql)
'Response.End()
cmd.CommandText = sql
cmd.Connection = con
Using sda As New SqlDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Using
End Using
End Using
End Sub
As usual, any help is greatly appreciated
|
|
|
|
|
Why are you using text strings for dates instead of DateTime types, and textboxes instead of Date pickers?
|
|
|
|
|
Hi Richard,
Thanks for your response however, I am not sure I understand your question.
Where did you see me use text strings?
|
|
|
|
|
In your command parameters e.g:
cmd.Parameters.AddWithValue("@start", date_start.Text)
, and the textboxes in your form.
|
|
|
|
|
Hmm, still confused.
The textboxes in my form are populated by selecting date from datepicker.
How would have coded the form?
|
|
|
|
|
Try something like:
Dim startDate As DateTime
If DateTime.TryParse(date_start.Text, startDate) Then
cmd.Parameters.AddWithValue("@start", startDate)
Else
cmd.Parameters.AddWithValue("@start", DBNull.Value)
End If
DateTime.TryParse Method (System) | Microsoft Docs[^]
If the date picker's format doesn't match the server's regional settings, then you may need to use DateTime.TryParseExact Method[^] instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|