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

Top 5 Contributors of the Month
Post New Web Links

FormView Disappears or gives a SQL Conversion Error

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

I am using a gridview for control parameters for a formview on the same page.

I keep getting the SQL Error below.  I have painfully looked through the code to see what the deal is and I have a feeling it has to do with the control parameter. When I test the query in the wizard it gives me back what I should get back.

When I run the page and code I get the error below. This value is the CorpID and it is a varchar. So I am thinking the way the parameters are configured is not correct.

I have no issues with the Insert Template, just the edit template. So it eithers gives me the SQL error or the Formview does not appear.

Any guidance on how to map the parameters from a GrdiView would be aprreciated.

SQL Error:Conversion failed when converting the varchar value 'X123456' to data type int.

SQL for Form View

select userid, FirstName , LastName ,PermissionLevelDesc, a.Permissionlevelid as permissionlevelid,
case active_flg when 1 then 'Active'
else 'Inactive' end as Active_Status,active_flg,CorpID
from dbo.NPE_APP_Users a inner join dbo.NPE_APP_SEC_PROFILE b
on a.PermissionLevelID = b.PermissionLevelID
where userid = @userid and corpid=@corpid and a.permissionlevelid=@permissionlevel

View Complete Post

More Related Resource Links

DropDownList within FormView Error

I have a FormView which works find and I have added a new DropDownList within the form which references another table to which I need to select a value,
I have added the dropdownlist2 and setup a new connection string to this, when I run the page I get this error:

Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.

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.InvalidOperationException: Could not find control 'DropDownList2' in ControlParameter 'CurrencyID'.
any help would be greatly

Requested Conversion is not supported, error while processing the partition

I have read the other topics that are related this issue and I thought that my issue was related as well until I checked the datatypes of all my measures and made sure that they indeed could be inherited properly.   I even went as far as deleting all measures out the measure group and I still recieved this error.   Is there a way I get more detailed information on what is not being converted properly?  The error is so vague and again, I have thouroughly checked my datatypes and they are fine and why would the partition not process, throwing me the exact same error when I decided to take out all measures in the measure group.   Here the second strange thing, I know that it has to be data related because I also ran the process structure and that finished with success. Please let me know if there is a better way to find the problem child or problem children pertaining to my measure group when processing data Here is a last thought, do you think that it could have something to do with the datasize?  I know SSAS automatically converts the datasize and I see several in my measures that have a zero for the size, I am speculating that could be wrong but is there a way I can check the datasize by running the script on my fact table?   ThanksNetwork Analyst

Update in formview doesn't work, but I don't get an error message?

I have a datasource:<asp:SqlDataSource ID="MySQLProfielDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:WAPMySQLConnStr %>" InsertCommand="INSERT INTO usergegevens(UserId, Geslacht, Voornaam, Tussenvoegsel, Achternaam, Adres, Huisnummer_toev, Postcode, Woonplaats, TelnrV, TelnrM, Geboortedatum) VALUES (@Param1, @Param2, @Param3, @Param4, @Param5, @Param6, @Param7, @Param8, @Param9, @Param10, @Param11, @Param12)" ProviderName="<%$ ConnectionStrings:WAPMySQLConnStr.ProviderName %>" SelectCommand="SELECT UserId, Geslacht, Voornaam, Tussenvoegsel, Achternaam, Adres, Huisnummer_toev, Postcode, Woonplaats, TelnrV, TelnrM, Geboortedatum FROM usergegevens WHERE (UserId = @Param1)" UpdateCommand="UPDATE usergegevens SET Geslacht = @Param1, Voornaam = @Param2, Tussenvoegsel = @Param3, Achternaam = @Param4, Adres = @Param5, Huisnummer_toev = @Param6, Postcode = @Param7, Woonplaats = @Param8, TelnrV = @Param9, TelnrM = @Param10, Geboortedatum = @Param11 WHERE (UserId = @Param12)" onselecting="MySQLProfielDataSource_Selecting" onupdating="MySQLProfielDataSource_Updating" onselected="MySQLProfielDataSource

Help to resolve an error "The conversion of a char data type to a datetime data type resulted in an

Why am I getting an error when executing this: select convert(datetime, '2010-09-12T18:11:48', 120) The message is: "Msg 242, Level 16, State 3, Line 1 The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value." I don’t get the error if I remove “T” from the string. But I need it to work with “T”.

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, 

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

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



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
            cmd.Connection = objectconnection
            cmd.CommandText = command
            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

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

DateTime conversion Error

I am getting the following error while executing a SSIS package.
[OLE DB Destination [760]] Error: There was an error with input column "RecordEffectiveDate" (828) on input "OLE DB Destination Input" (773).
 The column status returned was: "Conversion failed because the data value overflowed the specified type.".


Source is a non sql server with datetime datatype and the data like 10/20/2004 2:23:27 PM
and the sql server destination datatype is datetime.


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

Data Conversion Task Error


Hi All, i have a table in excel as below. and i am trying to move records from excel to SQL.

Code     Template      ExportType

A002      A002XM08    DST           

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

I have simple SSIS package with Excel Source, data conversion task and OLEDB Destination. and in data conversion i have given the data type string(DT_STR) for each of the column and length of data type same as each column is having in sql database but still it fails at data conversion task and gives the following error: 


Error: 0xC02020C5 at Data Flow Task, Data Conversion [2329]: Data conversion failed while converting column " ExportType" (3519) to column "Copy of ExportType" (3533). The conversion returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".

Error: 0xC020902A at Data Flow Task, Data Conversion [2329]: The "output column "Copy of ExportType" (3533)" failed because truncation occurred, and the tr

FormView Error when inserting


When doing an insert using a FormView i get the following error.

"Could not find a property named 'Project.IID' on the type specified by the DataObjectTypeName property in ObjectDataSource 'UserStoryDataSource' "

Other posts have suggested removing the value from the DataObjectTypeName. Which I have done but that just results in the error "ObjectDataSource 'UserStoryDataSource' could not find a non-generic method 'Save' that has parameters: ListItemID, UserStoryID, Name, Project.IID, AsUser, Action, Reason, Priority, Complexity, Story."

I think the error has something to do with the binding the Selected Value of the Project drop down list to the Project.IID property of the UserStoryDTO class.

What is the cause of this error and how can i fix it?

The insert Item template and datasource code is below.

                <asp:Label runat="server" AssociatedControlID="ListItemIDTextBox">ListItemID</asp:Label>
                <asp:TextBox ID="ListItemIDTextBox" runat="server"  Text='<%# Bind("ListItemID") %>' />
                <br />
                <asp:Label ID="Label1" runat="server" AssociatedControlID="Lis

Interesting javascript error with formview


hii.. I have a formview which implements the edit, delete and new operations on database. The form is working absolutely fine. But now i had inserted the code of the formview into a modalbox created through javascript.

The form now displaying the data perfectly. But, when i click on any buttons to do any operation.. it is throwing an exception at the following line..


and the exception throwed is

Microsoft JScript runtime error: Object expected

Can some one tell me what is the problem..

I want to post to server from the modalbox form. Please explain if we can directly post back to server from modalbox or not ?

Date Time conversion error


Hello all

I am trying to create a stored procedure that filters data from sql server by date but i get this error:

Conversion failed when converting datetime from character string.

my stored procedure is like:

CREATE PROCEDURE [dbo].[frRecordsUniqueBProductAndDatesSortedBDate]
	@productId int, 
	@dateFrom DateTime,
	@dateTo DateTime
DECLARE @sql nvarchar(4000)
DECLARE @productIdFilter nvarchar(10)
DECLARE @dateFromFilter DateTime
DECLARE @dateToFilter DateTime

SET @productIdFilter = Convert(nvarchar(10), @productId)
SET @dateFromFilter = Convert(DateTime, @dateFrom)
SET @dateToFilter = Convert(DateTime, @dateTo)

Set @sql = 
'select * from tableName where productId = ' + @productIdFilter +
' and myDate >= ' + @dateFromFilter + 
' and myDate <= ' + @dateToFilter

the parameters are passed to the stored procedures as dateTime variables from c# code...

any suggestions?

US to AUS Date time conversion error


hi all,

i have date like this in the US format 12/25/2010 in string and want to convert it into AUS format, 25/12/2010,  and then convert it into a string, can someone help me out here??


when i use DateTime.Parse i get the following error

String was not recognized as a valid DateTime. 



Conversion error in the JDBC 3.0 driver when accessing metadata


I am using SQL Server 2008 R2 and the SQL Server JDBC driver 3.0.1301.101.

When reading meta data for a table I get the following SQLServerException on column 22 (SOURCE_DATA_TYPE)

The conversion from char to SMALLINT is unsupported.

The following code demonstates the problem.

import java.sql.*;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;

public class SQLJDBCTest {

 public static void main(String[] args) {
  SQLServerDataSource ds = new SQLServerDataSource();

  Connection cn = null;
  ResultSet rs = null;
  try {
   cn = ds.getConnection();
   rs = cn.getMetaData().getColumns("Archive25", "dbo", "CountryCode", null);
   if(rs != null) {
    ResultSetMetaData rsm = rs.getMetaData();
    while(rs.next()) {
     for(int i = 1; i <= rsm.getColumnCount(); ++i) {
      String cname = rsm.getColumnName(i);
      Object obj = rs.getObject(i);
      System.out.println(cname + " " +obj);
  }catch(Exception ex) {


Document Conversion error 6102


This error:

6102 Critical LoadBalancer.RegisterLauncher failed:  The underlying connection was closed: An unexpected error occurred on a send.

is followed by:

7jgs Medium   Loadbalancer not running or available to launcher id 1

I have 2 wfe's running the launchers under the local system account and a single balancer running under the Network System ona dedicated machine. The 2 wfes are under Microsoft Network Load Balancer.

When I run the conversion I get the CS_BACKENDUNAVAILABLE.

The steps I have taken in an effort to resolve the problem (shown below) resulted in a single change:

"6102 Critical LoadBalancer.RegisterLauncher failed:  Unable to connect to the remote server "

changed to

"6102 Critical LoadBalancer.RegisterLauncher failed:  The underlying connection was closed: An unexpected error occurred on a send."

Here are the steps I took to accomplish that:

1. Delete the HVU_ user account from all servers in the farm.
  Go to Computer Management --> Local users and Groups --> Users. Right click the HVU_ user and select delete.

2. Stop the Load Balance Service & Document Launcher service.
 Use Central Admin or use  stsadmin commands on the servers.


Program for Format Conversion of An Image

.NET provides extensive support for image conversion. Any image can be processed from one format to another. Most common formats to which .NET have support for are .BMP, .EMF, .GIF, .ICO, .JPG, .PNG, .TIF and .WMF.

Conversion of text files from ANSI to UTF-8

reading and writing text files in ANSI format and
writing html-files in Charset ISO-8859-1 (Western Europe).
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