.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Post New Web Links

WebSecurity covert string to int error?

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
 
Server Error in '/dev' Application. Cannot convert type 'string' to 'int' Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot convert type 'string' to 'int' Source Error: Line 12: login_password = Request.Form["login_password"]; Line 13: string login_username = Request.Form["login_username"]; Line 14: if(WebSecurity.Login(login_username, login_password)){ Line 15: Response.Redirect("~/"); Line 16: } Source File: c:\WWW\cisatools.com\apps\csg\dev\login.cshtml Line: 14 Stack Trace: [RuntimeBinderException: Cannot convert type 'string' to 'int'] CallSite.Target(Closure , CallSite , Object ) +216 System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +344 Microsoft.WebPages.SimpleMembershipProvider.GetUserId(Database db, String userTableName, String userNameColumn, String userIdColumn, String userName) +1199 Microsoft.WebPages.SimpleMembershipProvider.VerifyUserNameHasConfirmedAccount(Database db, String username, Boolean throwException) +51 Microsoft.WebPages.SimpleMembershipProvider.Vali


View Complete Post


More Related Resource Links

error in MVC2 on empty string form fields which are required: "This property cannot be set to a null

  
In model I have:[DisplayName("ISBN")] [Required(ErrorMessage = "ISBN is required.")] [StringLength(50, ErrorMessage = "ISBN book must have max {1} chars.")] [DisplayFormat(ConvertEmptyStringToNull = false)] public string isbn { get; set; }But when I submit form with empty field ISBN I have an error - ConstraintException: This property cannot be set to a null value.I have find that other people have the same problem and they say that debbugger in VS2010 works wrong - yes ?http://p2p.wrox.com/book-professional-asp-net-mvc-2/79788-constraintexception-unhandled-user-code.html#post259245http://efreedom.com/Question/1-3129080/Server-Side-Validation-REQUIRED-String-Property-MVC2-Entity-Framework-Workhttp://mvcmusicstore.codeplex.com/workitem/6604

WebSecurity.CreateAccount ERROR

  
Server Error in '/' Application. The Provider encountered an unknown error. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.Security.MembershipCreateUserException: The Provider encountered an unknown error. Source Error: Line 32: // WebSecurity Errors? Line 33: if(execute){ Line 34: WebSecurity.CreateAccount(username, password); Line 35: } Line 36: else{ Source File: c:\Users\template\_register.cshtml Line: 34 Stack Trace: [MembershipCreateUserException: The Provider encountered an unknown error.] Microsoft.WebPages.SimpleMembershipProvider.CreateAccount(String userName, String password, Boolean requireConfirmationToken) +1246 Microsoft.WebPages.Helpers.WebSecurity.CreateAccount(String userName, String password, Boolean requireConfirmationToken, Boolean persistCookie) +46 ASP._register_cshtml.Execute() in c:\Users\template\_register.cshtml:34 Microsoft.WebPages.WebPageBase.ExecutePageHierarchy() +152 Microsoft.WebPages.<>c__DisplayClass7.<RenderPage>b__6(TextWriter writer) +168 Microsoft.WebPages.Helpers.HelperResult.WriteTo(TextWriter writer) +12 Microsoft.WebPages.We

error: cannot implicitly convert type 'string' to 'int?'

  
Hey guys,I am trying yo build the following class for which i get an error on the line this.id = e.id as cannot implicitly convert type 'string' to 'int?'. can anybody help me with it??many many Thanks,Chetan.using System;using System.Collections;using System.Collections.Generic;using System.Linq;using System.Data.Linq;using System.Text;using System.Runtime.Serialization;using HsInternet.Data.DAL;namespace HsInternet.Data.BLL{    public class Baby    {        public int id { get; set; }        public string name { get; set; }        public string parents { get; set; }        public int gender { get; set; }        public string weight { get; set; }        public string length { get; set; }        public DateTime date { get; set; }        public DateTime time { get; set; }        public string image { get; set; }        public string ipa { get; set; }        public string ipb { get; set; }        public Baby()  &

Simple error connection string null reference

  
 It is failing on SqlHelper.ExecuteNonQuery(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString     public static string GetAboutMeName(string sUserID, string connectionString)        {             SqlParameter[] parameters = new SqlParameter[2];                      parameters[0] = new SqlParameter("@sUserID", SqlDbType.VarChar, 50);            parameters[0].Value = sUserID;             parameters[1] = new SqlParameter("@sResult", SqlDbType.NVarChar, 1000);            parameters[1].Direction = ParameterDirection.Output;             // Execute the stored procedure            SqlHelper.ExecuteNonQuery(System.Configuration.ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString, CommandType.StoredProcedure, "sprGetAboutMeName", parameters);         &n

statement with SQL_C_WCHAR returns 22001 string data, right truncation error

  
I am trying to execute the following code  value = L"Test13Digit++"; SQLPrepare(stmt, L"delete Entries where [type] = ?", SQL_NTS); SQLBindParameter(stmt, paramNumber, SQL_PARAM_INPUT, SQL_C_WCHAR, SQL_WVARCHAR, 100, 0, (SQLPOINTER) value.c_str(), 0, &strLen); SQLExecute(stmt); the table entries is as follows: Entries ([type] nvarchar(100), [key] nvarchar(100), [version] bigint, [data] varbinary(8000), CONSTRAINT PK_Entries PRIMARY KEY([type], [key]))   I keep getting the 22001 - string data, right truncation error. I have tried all different versions of WCHAR types but does not seem to help.

Runtime error in string builder which was declared static

  

My code to insert data is as follows it works for the first time if i tried to insert data for the second time i am getting the error

My complete code

 

 

using
 
System
;

using System . Collections . Generic ;
using System . Text ;
using System . IO ;
namespace ACHDAL
{
public class EntryDetail
{

   
int [] debits ={ 25 , 26 , 27 , 28 , 29 , 35 , 36 , 37 ,

Runtime error in string builder which was declared static

  

My code to insert data is as follows it works for the first time if i tried to insert data for the second time i am getting the error

object reference not set to an object

 


SQL error: Conversion failed when converting date and/or time from character string.

  
I hope someone can advise on the issue I'm having.

This SQL worked beautiful until I added in @startdt and @enddt and this section >> AND [Selldate] BETWEEN ' + @startdt + ' AND ' + @enddt + '

By adding in this condition, I now get the following error:

Msg 241, Level 16, State 1, Line 8
Conversion failed when converting date and/or time from character string.

I have tried changed variables to type = date and various iterations of date formatting, casting with no success. The date in the table is clean as a whistle.

(The CONVERT function is being used in setup for a PIVOT SQL which needs  VARCHAR for column headers)

Thanks in advance for your help, 
JR

declare @itemID varchar(20)
declare @startdt varchar(12)
declare @enddt varchar(12)
set @itemID = ''
set

Web config connection string error: a field initializer can not reference the nonstatic field

  

Hello:

I am try to get connection string from web config, but I got error" a field initializer can not reference the nonstatic field, method, or property '_default.connStr'. I search a lot. It says that I need constructor, but I am not sure how to write the constructor at class: public partial class _Default : System.Web.UI.Page


Here is my code:

{public partial class _Default : System.Web.UI.Page

    string txt;
    string username;
    OleDbCommand myCommand = null;
    OleDbDataReader myDataReader = null;
 

//retrieve the connection string from the ConnectionString Key in Web.Config
    string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

    //create a new OleDB connection
    OleDbConnection myConnection = new OleDbConnection(connStr);

protected void Page_Load(object sender, EventArgs e)
    {

            string strOledb = @"select * from tableone";
     
            OleDbCommand myCommand = new OleDbCommand(strOledb);

Help me with this error Format of the initialization string does not conform to specification starti

  

I am getting this error-- Format of the initialization string does not conform to specification starting at index 0. whenever i want to insert some record into DB using store procedures.

 String cstr = ConfigurationManager.ConnectionStrings["cstr"].ConnectionString;
       SqlConnection con = new SqlConnection("cstr"); 
        cmd = new SqlCommand("insert1", con);
         
        cmd.CommandType = CommandType.StoredProcedure;  
           
         cmd.Parameters.Add(new SqlParameter("@empid", SqlDbType.VarChar)).Value = TextBox1.Text;  
         cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar)).Value = TextBox2.Text;  
                   
         con.Open();  
         cmd.ExecuteNonQuery();  
         con.Close();   

and my connection string in web.config

<configuration>
	<configSections>
		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35

ERROR-Conversion from string "'," to type 'Double' is not valid

  

Hello,

I am having  badly stuck!!I have spent hours in trying to solve that.

I am having the following loving function:

 

   Public Function InsertDeleteUpdate(ByVal command As String) As Boolean
        Try
            open_connection()
            objectconnection.Open()
            cmd.Connection = objectconnection
            cmd.CommandText = command
            cmd.ExecuteNonQuery()
            objectconnection.Close()
            Return True
        Catch ex As Exception
            Return False
End Try


 In the above function I pass the following string:

gridcost = Convert.ToDecimal(txtcost.Text)
_date = Convert.ToDateTime(txtdatefrom.Text)
patient = Convert.ToInt32(ddlpatients.SelectedValue)


 sqlstring = "execute dbo.InsertDeleteUpdate " & patient & ",'" & _date + "'," & gridcost & ",'" & txtinsurances.Text & "','" & checkreceipt.Checked + "'," & appointment_xid
InsertDeleteUpdate(sqlstring)

The string includes a stored procedure.The store procedure includes the following parameters:

Error: The variable System::ErrorDescription contains a string that exceeds the maximum allowed leng

  
Hi,

i get the following error message, when I try to email the error description, by invoking a 'Send Mail Task' in OnError event.

"Error: The variable System::ErrorDescription contains a string that exceeds the maximum allowed length of 4000 characters."

Any idea how to resolve this issue? I am using substring when I build the expression. But still am facing this issue.

Error Message: String or binary data would be truncated. The statement has been terminated

  

Hello,

 

I have the following problem.

When I edit a field in the SQL Server Management Studio Express then I get the following error:

Error Source: .Net SqlClient Data Provider
Error Message: String or binary data would be truncated.

The statement has been terminated

 

When I use the SQL update commando, it works fine.

Fore debugging we need to change the enabled field several times.

Is there a solution fore this?

 

 

The Table Layout

USE [Project]

GO

/****** Object: Table [dbo].[Proces] Script Date: 06/02/2008 10:01:20 ******/

SSIS Error in Script task: "Conversion from string "C002" to type 'Integer' is not valid"

  

Hi All,

I have a script component in my Dataflow that generates Error Description string.

But I am not trying to convert anything in my Script as you can see below.

Here is the Code inside the SCR_component.

-----------------------------------------------

Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper


Public Class ScriptMain
    Inherits UserComponent
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
     'Use the incoming error number as a parameter to GetErrorDescription
    Row.ErrorDescription = ComponentMetaData.GetErrorDescription(Row.ErrorCode)
   End Sub
End Class

-------------------------------------------------

When I run the package , it fails at this script task with the following error:

Description: System.InvalidCastException: Conversion from string "C002" to type 'Integer' is not valid.

 

The value "C002" is actually a column in the metadata and its type is "DT_STR". I am not trying to convert it in my Script as you can see

Enterprise Library 4.0 error: Input string was not in a correct format.

  

I am trying to insert candidates information into SQL Server database. I have written the corresponding stored procedure like below in SQL server:

ALTER PROCEDURE [dbo].[USPInsertCandidate]
	@candidate_name varchar(60),
	@dob datetime,
	@gender char,
	@current_location varchar(60),
	@mobile_no_one varchar(20),
	@mobile_no_two varchar(20),
	@home_phone	varchar(20),
	@work_phone varchar(20),
	@email_id varchar(100),
	@passport varchar(20),
	@as_on_date datetime,
	@file_upload_path varchar(255),
	@availability char,
	@applied_position varchar(30),
	@max_round_id int,
	@certification_comment varchar(2000),
	@source_id int,
	@source_comment varchar(2000),
	@skillset_comment varchar(2000),
	@max_status_id int,
	@total_exp_year int,
	@total_exp_month int,
	@source_date datetime,
	@user_id int,
	@visa varchar(20),
	@qualification varchar(100)
AS
BEGIN
	declare @candidate_id int;
	set @candidate_id = dbo.GetCandidateID();
	insert into candidates(candidate_id, candidate_name, dob, gender, current_location, mobile_no_one, mobile_no_two, home_phone, work_phone, email_id, 
							passport, as_on_date, file_upload_path, availability, applied_position, max_round_id, certification_comment,
							source_id, source_comment, skillset_comment, max_status_id, total_exp_year, total_exp_month, source_date,
							user_id, visa, qualification)
	values

Safe Connection String error when installing new

  

I am trying to install a new SharePoint2010 WSF on a Virtual Server.

Team Foundation Server already runs fine.

I run the Install and everytime I either point to a databasde or let SharePoint create it's own I get the following error.

Here my flickr picture of the message box.

http://farm2.static.flickr.com/1100/5097592925_4e7a50ab02_m.jpg 

It's safe.

Its a missing method exception  ( System.String.Microsoft.SharePoint.Administration.SPSqlConntionString.GetWYukonSafeConnectionString(String)

Did I download the wrong setup file?

We have a 2003 WSS SharePoint and I'm trying to take thier old database and attach it and upgrade them to 2010 on a test Virtual first.

Any pointers, links, or advice is appreciated.

Thanks,

Nick

 


cannot convert string to bool error in LINQ

  

hi guys,

this is my code:


DataClassesDataContext db = new DataClassesDataContext();
        item it = new item();

        var items = from p in db.items
                    where p.id = TextBox1.Text
                    select p;


        GridView1.DataSource = items;
        GridView1.DataBind();


an error message at line 5 says:

  Cannot implicitly convert type 'string' to 'bool'


the id attribute on the items table is of varchar(50) type. and the text box too is of string type.

so why does it says conversion between boolean and string problem?


thank you all.


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend