|
Hi
See the difference below statements
exec IsValidLogin 'username','123456','sdf'
:If you run the above statement it is throwing error 'Error converting data type varchar to int':
exec IsValidLogin @username='harini',@password='123456',@userfullname='sdf'
:No error in executing this statement:
Solution 1:
Change the order of output parameters as
@username varchar(50) ,<br />
@password varchar(12) , <br />
@userfullname varchar(50) OUTPUT,<br />
@userid int=0 OUTPUT
Solution 2:
Pass maximum value for parameter @userid from code-behind without changing the order of output parameters.
Try any of the above solutions and let me know.
Hope you got it.
Harini
|
|
|
|
|
Harini Krishnaswamy wrote:
exec IsValidLogin 'username','123456','sdf'
:If you run the above statement it is throwing error 'Error converting data type varchar to int':
Yes, that is a different way of getting the same error message, but I don't see the relevance?
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,
Thanks for the reply, I think this might work too.
I got an earlier post which I switch from AddWithValue to Add as using AddWithValue cause it to add the value and it become me adding 4 integer value.
J Liang
|
|
|
|
|
This is not strange at all.
When you use the AddWithValue method to create parameters, the second argument is not the data type, but the value. Therefore you are creating four parameters with the type int (as int would be the type used to send the enum values to the database).
Use the Add method instead to specify the data type, and also specify the size of the varchar fields:
objParam1 = myCommand.Parameters.Add("@username", SqlDbType.VarChar, 50);<br />
objParam2 = myCommand.Parameters.Add("@password", SqlDbType.VarChar, 12);<br />
objParam3 = myCommand.Parameters.Add("@userid", SqlDbType.Int);<br />
objParam4 = myCommand.Parameters.Add("@userfullname", SqlDbType.VarChar, 50);
---
single minded; short sighted; long gone;
|
|
|
|
|
Hey,
Thanks, this way works well, didnt really understood the difference of Add and AddWithValue until now.
J Liang
|
|
|
|
|
|
Hello, first let me say that I am a newbie to .Net, so please be gentle. I've been registered on this site for a while, but I recently started by first .Net developer job, so I'll probably be posting here frequently now!
I am developing a custom server control to be used for a Web Part. All of the controls are created dynamically (not using the designer). I am gathering several user input fields via a DetailsView control. I need to validate the user input, but all of the examples I can find use a Template added to the HTML. Since I am not using the designer, I don't have the HTML, except for what I render myself.
So my question is, how do I render the HTML in such a way as to be able to add user input validation?
Thanks for your help!
|
|
|
|
|
I am trying cascadingdropdown with ajax control. On my form i add 1
combobox and the cascadingdropdown control. When I run the page the
combobox displays the Select... and no options except for
[Method Error 500]
Please help me.
Here is my web service code.
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using AjaxControlToolkit;
using System.Data;
using System.Data.SqlClient;
///
/// Summary description for FoodService
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class FoodService : System.Web.Services.WebService
{
public FoodService()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
// public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues, string category)
// {
// string[] _categoryValues = KnownCategoryValues.Split(':',
';');
// int _foodID = Convert.ToInt32(_categoryValues[1]);
// List<cascadingdropdownnamevalue> _foodItems = new
List<cascadingdropdownnamevalue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
// foreach (DataRow _row in _foodAdapter.GetFoodData())
// {
// _foodItems.Add(new
CascadingDropDownNameValue(_row["category"].ToString(),
_row["categoryID"].ToString()));
// }
// // convert to array and return the vlaues
// return _foodItems.ToArray();
// }
public CascadingDropDownNameValue[] GetItemsByCategoryID(string
KnownCategoryValues)
{
string[] _categoryValues = KnownCategoryValues.Split(':',
';');
int _foodID = Convert.ToInt32(_categoryValues[1]);
List<cascadingdropdownnamevalue> _foodItems = new
List<cascadingdropdownnamevalue>();
// dsFoodTableAdapters.tbparentTableAdapter _foodAdapter =
//new dsFoodTableAdapters.tbparentTableAdapter();
dsFoodItemsTableAdapters.tbChildTableAdapter _foodAdapter =
new dsFoodItemsTableAdapters.tbChildTableAdapter();
foreach (DataRow _row in _foodAdapter.GetData(_foodID))
{
_foodItems.Add(new
CascadingDropDownNameValue(_row["subcategory"].ToString(),
_row["subcategoryID"].ToString()));
}
// convert to array and return the vlaues
return _foodItems.ToArray();
}
}
#######################################
Below is the code for aspx page
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<title>Untitled Page
<asp:scriptmanager id="ScriptManager1" runat="server">
<asp:dropdownlist id="DropDownList1" runat="server"
datasourceid="ObjectDataSource1"
="" datatextfield="category" datavaluefield="categoryID">
<asp:objectdatasource
id="ObjectDataSource1" runat="server"
oldvaluesparameterformatstring="original_{0}"
="" selectmethod="GetFoodData"
typename="dsFoodTableAdapters.tbparentTableAdapter">
<asp:dropdownlist id="DropDownList2" runat="server">
<cc1:cascadingdropdown id="CascadingDropDown1" runat="server"
category="tbChild" loadingtext="please wait"
parentcontrolid="DropDownList1" prompttext="please subcategory"
servicemethod="GetItemsByCategoryID" targetcontrolid="DropDownList2">
seema
|
|
|
|
|
seemamltn wrote: tempuri
This is not a reference to fried food coating ( that's tempura ). It means temp uri, and should never appear in a production web service, you're supposed to change it.
This is not the problem, I just thought I'd mention it.
What happens if you set breakpoints in your code and step through the AJAX call ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
Why my date time picker, work normally in aspx form, and don't work in ascx form?
Is anybody know?
thank you
|
|
|
|
|
Well, how could we possibly ? We don't even know which control you're using, let alone what the code looks like.
An ascx gets rolled into the aspx, so there's a reason that's specific to your code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
if (Request.QueryString["textbox"] != "")
{
string strScript = "window.opener.document.forms(0)." + Request.QueryString["textbox"].ToString() + ".value = '";
strScript += Calendar.SelectedDate.ToString("dd/MM/yyyy");
strScript += "';self.close()";
strScript += "</" + "script>";
RegisterClientScriptBlock("Calendar_ChangeDate", strScript);
}
|
|
|
|
|
Hi All,
I have some ASP.Net web pages that use C# as code behind. On those ASPX pages, there r some datagrids that I want to print.
I have seen help about printing datagrids on standalone applications but dont know how to do it on WebBased applications such as mine.
Any help/ideas/urls wud be greatly appreciated
Thanx
Umashanker.k
|
|
|
|
|
Try the below mentioned code:-
<script language=javascript>
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
prtContent.innerHTML=strOldOne;
}
</script>
<div id="divPrint">
<asp:datagrid>
.....
.....
.....
</asp:datagrid>
</div>
<asp:button ID="btnPrint" onClick="javascript:CallPrint('divPrint');" Runat=Server />
|
|
|
|
|
Hi, I am using a wizard control, and I notice that when it places the "next" button, it puts this in a table, then in a td with align=right specified as a style.
Now I want to remove this style. I thought the best way to do this is to override the control, however if i do that, I cannot find what the rendered html looks like to overwrite. Does anyone know how you can overwrite this before the control gets generated?
|
|
|
|
|
hello all l am student of computer engineer and l was given a project at that point l need help about problem that is l want to create a ftp user acount and l want to make relatoin between that user account and virtual directory for example;
l creat a user acount:
user name:jack
pasword:*****
let say our vitual directory directory is www.mst.edu
now question is what l want to learn is how can l illustrate that vitual directory with username ?
when l typed at the adressbar www.mst.edu/jack l want to see account of jack
please help me...l already thaks who keep knowledge exchange!
by the way l use asp.net 2005 whit framework 2.0 and please tell me how should l open new project in viual studio.net step by step for this problem
Engineerusa
|
|
|
|
|
Hi
I am after a bit of help, I have a paged datasource displayed in a repeater which is working fine for me. The number of rows returned is populated from a ddl and is either 10, 20 or 50. This works ace and is brill. However I want to have another option for all. In which case all the rows are returned and only one page is shown. I have currently got the pagesize set to 2000000 which is not exactly ideal is it? Would like it so that it will just show them all rather than restricting to a page size no matter how large a one that I pick. Is there any ideas?
Cheers
Ian
|
|
|
|
|
Why don't you just turn paging off. That should do it.
Ben
|
|
|
|
|
Good plan although I am not sure how I can do this using my code. I mean I know its possible but just having a mental block, been looking at it for ages now and all the words are jumbling into one!
I have a load data method which populates my repeater.
' This Method is responsible for reloading the data when a user event like a sort or <br />
' a filter is applied to the user control<br />
Private Sub LoadData(ByVal b As Boolean)<br />
'I need to load all my data into the repeater control.<br />
Dim strConnectionString As String = sqlViewCalls.ConnectionString<br />
<br />
Dim sqlConnection As SqlConnection = New SqlConnection(strConnectionString)<br />
sqlConnection.Open()<br />
<br />
Dim sqlDA As SqlDataAdapter<br />
sqlDA = New SqlDataAdapter(hidViewString.Value.ToString() & hidQueryString.Value.ToString() & hidSortString.Value.ToString(), sqlConnection)<br />
<br />
Dim dt As DataTable<br />
dt = New DataTable()<br />
sqlDA.Fill(dt)<br />
sqlConnection.Close()<br />
<br />
' Create a new PagedDataSource<br />
Dim pgItems As PagedDataSource<br />
pgItems = New PagedDataSource()<br />
<br />
' Create a new DataView from the datatable we created before.<br />
Dim dv As DataView = New DataView(dt)<br />
' Initialise the PagedDataSource and populate it.<br />
pgItems.DataSource = dv<br />
pgItems.AllowPaging = True<br />
pgItems.PageSize = pgSize<br />
pgItems.CurrentPageIndex = PageNumber<br />
<br />
If b = True Then<br />
If pgItems.PageCount > 1 Then<br />
Dim pages As ArrayList = New ArrayList()<br />
For index As Integer = 0 To (pgItems.PageCount() - 1)<br />
pages.Add((index + 1).ToString())<br />
Next<br />
hidLast.Value = (pages.Count() - 1).ToString()<br />
Else<br />
hidLast.Value = 0<br />
End If<br />
End If<br />
<br />
lblPagination.Text = " Page: " & (pgItems.CurrentPageIndex + 1).ToString() & " of " & pgItems.PageCount & " (" & pgItems.DataSourceCount & " Records)"<br />
<br />
repResults.DataSource = pgItems<br />
repResults.DataBind()<br />
<br />
End Sub
Then in the selection Changed of the ddl (which is populated by 4 values, 10,20,50 and all) I have
<br />
Protected Sub ddlPageSize_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPageSize.SelectedIndexChanged<br />
If ddlPageSize.SelectedIndex = 3 Then<br />
pgSize = 2000000<br />
PageNumber = 0<br />
LoadData(True)<br />
' Code to enable buttons/disable buttons here<br />
Else<br />
pgSize = Integer.Parse(ddlPageSize.SelectedValue)<br />
PageNumber = 0<br />
LoadData(True)<br />
' Code to enable buttons/disable buttons here<br />
End If<br />
End Sub<br />
I commented out the paging buttons disabling/renabling but you get the idea. Anyhelp would be appreciated.
Cheers
Ian
|
|
|
|
|
In your load event I would check the dropdown index
So add some code like:
pgItems.DataSource = dv
If ddlPageSize.SelectedIndex = 3 Then
pgItems.AllowPaging = False
Else
pgItems.AllowPaging = True
pgItems.PageSize = pgSize
End If
When the dropdown event happens the pageload method is called again.
Hope that helps.
Ben
|
|
|
|
|
Thanks for your help,
That works great and is so obvious I can't believe I didn't think of it myself. Sometimes you can't see the wood for the trees can you? lol
Cheers
Ian
|
|
|
|
|
Glad it worked for you. Sometimes it just helps to bounce a question off someone else.
Ben
|
|
|
|
|
Hello!
We use IIS, ASP.NET 2.0. I added AJAX calendar to pages.
Everything was allright on localhost, but when we load new version on server it does not work.
But if we move project to the default directory wwwroot, evething is allright
Thank you.
Error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
|
|
|
|
|
You are most likely an admin on your local box. At least one of the functions your site is trying to do is requiring permission more then then aspnet user currently has.
So you have a couple of options. First you can give aspnet User on that web server the rights it needs. This is normally not a great idea since it can be a security risk.
You can set up a new app pool for the web site to run under and then create a new user for the app pools identity. Then you can give that user all the rights they need.
Hope that helps.
Ben
|
|
|
|
|
Hi, Ben, thank you for your help
Unfortunatly we try to create an app pool and user, but in that case we've got an error
Service Unavailable
I don't know what that mean.
Another action: we create app pool and set user IWAM_ blah blah
then we got an error failed to create smt in C:\WINDOWS\temp.....
Thank you
|
|
|
|