|
hi guys! briefly, i have an application which use an api for its interaction with another plattform.at this point a need to update my database with data from a call from that api which uses querystring to pass data.Simple and fairky straight foward but couldn't suceeded.and the funniest is it doesn't throw any error. tried for 3 days now to find out where the problem is without any changes.i'm sure it just a little thing but can't see it.i would like to ask for help on this. here is my codes
the page call.aspx that the api use as callback to pass the data is.
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
gid = Request["Id"];<br />
numbstatus = Request["status"];<br />
if(apimsgid != null && numbstatus != null)<br />
{<br />
gid = gid.Trim();<br />
numbstatus= numbstatus.Trim();<br />
if (gid != "" && numbstatus != "")<br />
{<br />
DatabaseLayer dlayerobj = new DatabaseLayer();<br />
<br />
Response.Write(dlayerobj.UpdateStatusByApiId(gid, numbstatus));<br />
}<br />
}<br />
<br />
}<br />
}<br />
<br />
now the function in the database layer is :
public string UpdateStatusByApiId(string theapiid, string thestatusnum)<br />
{<br />
string status = convertStatus(thestatusnum);<br />
try<br />
{<br />
SqlCommand updatecmd = new SqlCommand();<br />
updatecmd.CommandType = CommandType.Text; <br />
updatecmd.Connection = con;<br />
updatecmd.CommandText = "update TState set DStatus =@stat where Gid=@apid"; <br />
updatecmd.Parameters.Add("@stat", SqlDbType.VarChar, 20).Value = status;<br />
updatecmd.Parameters.Add("@apid", SqlDbType.VarChar, 128).Value = theapiid;<br />
updatecmd.ExecuteNonQuery();<br />
return theapiid + " : " + status;<br />
this also to see if the fucntion receives its param well and it receives it<br />
}<br />
catch (Exception ex)<br />
{<br />
misc.logerr(ex.ToString());<br />
return ex.ToString();<br />
}<br />
<br />
<br />
}<br />
please let me know cause i'm stacked here and can't move forward without this..
ps:can anyone tell me the best practice testing in debugging.i mean by that either using an hyperlink or from address bar
eager to learn
|
|
|
|
|
Hi,
First set a break point where you read the data from the QueryString and see whether it retuns the parsed data. (Note: Just check if the Querystring key you use ie: "Id" and "status" has the same spelling as from where you are parsing from.)
Also another hint is just parse these values manually to the Query and see whether its working..
And when adding the values to the parameter you could simply use
updatecmd.Parameters.AddWithValue("@apid, theapiid); Just some additional infor...
And assigned the value you retrive from ExecuteNonQuery to int variable and check if its greater than 0 before going for the next line...
And others seems to be fine...
Hope it helps..
Thx,
Gayani
|
|
|
|
|
I've decompiled a pre-compiled ASP.NET web site, and on the whole it is looking good, except for three pages. In the compiled site, each page has a reference to the assembly that contains its code behind class, e.g.
<%@ page language="C#" autoeventwireup="true" inherits="Staff.UserList, App_Web_t89rsyw_" %>
where App_Web_t89rsyw is the assembly that the page was compiled to. Now I have three different pages that point to exactly the same class, and it seems to only apply to one of the pages, i.e. only one of them has controls on it that match the code in the decompiled class.
This doesn't look like an attempt at obfuscation, because everything else is glaringly accessible and clear. It looks like maybe the site as I have been given it is broken. Is there any explanation for many pages sharing one code behind class?
|
|
|
|
|
I have a problem with ASP.NET and AJAX. I try to post a form in async postback but when I do this in firefox the newlines are \n and in IE they are \r\n which creates a problem when displaying it on the site. I need to replace every \n which is not preceded by \r but how do I do that? This does not happen in normal postback, then all newlines are \r\n.
command.Parameters.Add("?message", MySqlDbType.VarChar).Value = Regex.Replace(tbMessage.Text.ToString().Trim(), "\n NOT PRECEDED BY \r", "\r\n");
Is there a way to say a character should not be there in a regex pattern? how?
|
|
|
|
|
I've been testing different regex patterns but I can't get it to work properly.
This looked promising: [^\r]\n it matches any character but \r before \n (I think) but the problem is it also replaces that character...
|
|
|
|
|
Hi,all:
Monthes before,Microsoft distributed the first MVC framework preview version,and 2 days before,MS give the the 5th preview version,My project is under VS2008+SP1+MVC framework preview 5
Here is my controller:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CMS.Models;
using CMS.Views;
using System.Web.Routing;
namespace CMS.Controllers
{
using CMSModel;
[Authorize]
public class CategoryController : Controller
{
private CategoryListDataContext database = new CategoryListDataContext();
CategoryRepository repository;
public CategoryController()
: this(new CategoryRepository(new CategoryListDataContext()))
{
}
public CategoryController(CategoryRepository context)
{
this.repository = context;
}
[HandleError]
public ActionResult Index()
{
ViewData["Title"] = "Category Manager";
ViewData["Message"] = "Category Manager";
var categoryList = from t in database.cms_categories
orderby t.id
select t;
ViewData["Category"] = categoryList;
return View(categoryList.ToList());
}
public ActionResult Edit(int id)
{
CategoryEditViewData viewData = new CategoryEditViewData();
cms_categories category = repository.Categories.SingleOrDefault(c => c.id == id);
if (TempData.ContainsKey("ErrorMessage"))
{
foreach (var item in TempData)
{
ViewData[item.Key] = item.Value;
}
}
ViewData["ParentCategory"] = new SelectList(repository.Categories.ToList(), "id", "name", ViewData["id"] ?? category.id);
ViewData["content"] = category.description;
return View("Edit",viewData);
}
public ActionResult Delete()
{
return View();
}
public ActionResult Publish()
{
return RedirectToAction("Index");
}
public ActionResult UnPublish()
{
return RedirectToAction("Index");
}
}
}
Models:
CategoryRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CMS.Models
{
public class CategoryRepository
{
CategoryListDataContext dataContext = null;
public CategoryRepository()
{
}
public CategoryRepository(CategoryListDataContext dataContext)
{
this.dataContext = dataContext;
}
public virtual IQueryable<cms_categories> Categories
{
get {
return this.dataContext.cms_categories;
}
}
public virtual void SubmitChanges()
{
this.dataContext.SubmitChanges();
}
public virtual void InsertCategoryOnSubmit(cms_categories p)
{
this.dataContext.cms_categories.InsertOnSubmit(p);
}
}
}
and CategoryViewData.cs
using System;
using System.Collections.Generic;
namespace CMS.Models
{
public class CategoryEditViewData
{
public cms_categories Category { get; set; }
public List<cms_categories> ParentCategory { get; set; }
}
public class CategoryNewViewData
{
public List<cms_categories> ParentCategory { get; set; }
}
}
and here is part of the code of the view page for EDIT
]]>
Problem is I can't use ViewData.Model.Category........
So anybody who can tell me what is the problem?
BTW: what does the sambol ?? means?
thanks.........
|
|
|
|
|
plz if u have solution den plz let me know.
thanks
Maniiiiiiiiiiiiiii
|
|
|
|
|
Yeah, just store them as a date data type.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Strings will be automatically formatted to SQL Server Format...
But you can do the standard which is : MMM-dd-yyyy
use toString("MMM-dd-yyyy") to format
Abhishek Sur
|
|
|
|
|
Abhishek sur wrote: But you can do the standard which is : MMM-dd-yyyy
use toString("MMM-dd-yyyy") to format
What do you mean by 'standard' ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi frnds,
I have a window based EXE and i want to run it over Internet..how can i run it ???
see.. basically,
My EXE save some data in SQL Database and now my exe installed on my machine and Databsase is at Remote location....can my EXE be run ??
how can i handle this issue ???
Thankx in advnace
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
This is not an ASP.NET issue. It's a C#/network communication issue.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi i have a checkbox list...,
Whenever i select a item from checkbox list i want to know which item has been selected...,
There is no event in checkboxlist like check changed event...,
so how to get it?,
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = "";
if (CheckBoxList1.Items[0].Selected == true)
Label1.Text = CheckBoxList1.Items[0].Text;
else if (CheckBoxList1.Items[1].Selected == true)
Label1.Text = CheckBoxList1.Items[1].Text;
}
Maniiiiiiiiiiiiiii
|
|
|
|
|
There is event for this called OnSelectedIndexChanged
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi,
AutoCompleteType = "Disabled" for textbox is not working in firefox.
if the user double-clicks the textbox it lists the already entered text...
i ve to block tat one....
Ashok
|
|
|
|
|
Hello,
I am writting website in ASP.net 2005 in hebrew, since now everything was OK until I start to use asp Label and validation control. When I am launching the site through the internet I get those controls in gibberish.
The site is hosted in Texas USA.
Can you help on this?
Thank you
Shay Noy
|
|
|
|
|
can you be clear and in brief manner what you r facing a problem with asplabel and validation controls
|
|
|
|
|
how to do templetes in vs2008.
how to set the layout in vs2008
your's subbu
|
|
|
|
|
try pressing F1 and using the help
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Anybody can tellme the difference between server.transfer and Response.redirect. Tnx in adv.
Balasubramanian K.
|
|
|
|
|
Response.redirect provides a roundtrip to the server and server.transfer does not. For details search microsoft IIS help
Also Response.redirect redirects both the html page as well as the aspx page where as the server.transfer transfers the control only to the aspx pages
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Thanks for your reply
Balasubramanian K.
|
|
|
|
|
server.transfer is used to transfer one page to anotherpage within the website.
response.redirect is used transfer one page to another page within the website as other websites.in response redirect we can pass the querystring.
your's subbu
|
|
|
|
|
can u give me any sample code for redirecting to other website by using response.redirect?
Balasubramanian K.
|
|
|
|