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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links


Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
In the following code, should we change the parameters from SqlDbType = SqlDbType.Int to SqlDbType.NVarChar?   protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlapplicationConnectionString"].ToString()); try { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO Application (" + " First, Last, City, State" + ") VALUES (" + " @First, @Last, @City, @State"; cmd.Parameters.Add(new SqlParameter() { ParameterName = "@First", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["First"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@Last", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["Last"]) }); cmd.Parameters.Add(new SqlParameter() { ParameterName = "@City", SqlDbType = SqlDbType.Int, Value = Convert.ToInt32(Request["City"])

View Complete Post

More Related Resource Links

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

I need help about nvarchar field



how can specified nvarchar data type without N''?

Conversion Failed when Converting the nvarchar value 'N' to data type int.

Hi.. I am facing a strange situation. when i executing the following query it is returning the error SELECT  s.row_id as shipment,    SUM(CAST(la5.attr_value AS INT)) AS Cases     FROM    shipment s WITH(NOLOCK)    INNER JOIN shipping_shift ss WITH(NOLOCK) ON s.shipping_shift = ss.row_id    INNER JOIN shift WITH(NOLOCK) ON ss.shift_id = shift.shift_id    INNER JOIN shipment_lot sl WITH(NOLOCK) ON s.po_id = sl.po_id AND s.cust_id = sl.cust_id AND          s.so_line_no = sl.so_line_no and s.ship_date_local = sl.ship_date_local     INNER JOIN lot_attr la5 WITH(NOLOCK) ON sl.lot_no = la5.lot_no AND sl.item_id = la5.item_id AND la5.attr_id = (SELECT attr_id FROM attr WITH(NOLOCK) WHERE attr_desc = 'CaseQty' AND attr_grp = 3)  WHERE s.spare2 = 'RELEASED'       AND shift.shift_desc = 'c'   AND DAY(ss.production_date) = DAY('2010-08-09 00:00:00.000')    AND MONTH(ss.production_date) = MONTH('2010-08-09 00:00:00.000')    AND YEAR(ss.production_date) = YEAR('2010-08-09 00:00:00.000') GROUP BY s.row_id  Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the nvarchar value 'N' to data type int. The column  type of attr_value of lot_attr table is a USER D

How to store binary data as nvarchar(max)?

I’m trying to store a blob of binary data as nvarchar(max) and it gets truncated after just a few bytes. I wonder why and how can I prevent it. I don’t use varbinary(max) because I’m trying to keep existing DB schema intact. Current DB contains a huge chunks of text in nvarchar(max) column and I’m trying to compress (zip) this text and store it back to the same field to reduce DB size.   DB is accessed using Sync Framework (and Entity Framework) on the client side, so actual DB engine is SQL Server Compact 3.5 SP2   Thank you! KonstantinThank you! Konstantin

can i use nvarchar(300) for a column having records as website links?

Hi guys, small question. is it good to use nvarchar(300) for a column having records as website links. i was told the size may exceed 255 characters. so just thinking is it possible?

How do I suppress the creation of nchar(), nvarchar()

Some of the wizards and import tools that create tables use nchar() and nvarchar() for character fields. Also the upgrade wizard from Access does the same thing. Is there a way to prevent the creation of nchar() and varchar() fields and to use char() and varchar()? Is there some TSQL I can use to pass over the exisitng tables and conver the datatypes?

Making my own CMS - What if an article is more than NVARCHAR(MAX)

Hi,I'm looking to create my own cms and just thought of something that could be a problem.What if I write an article that is in excess of what NVARCHAR(Max) can store?What would you do?Run a quick bit of code to separate the article into smaller chunks?Or is there a better way?I know I could create some sort of key system where there is an "article" primary key and in the same table, there would be an "article part" integer, then run a query when I want to display the article to stick it back together, but is it a good idea or am I over complicating it?Thanks

Dynamic SQL query cannot store more than 4000 characters even with NVARCHAR(MAX)

Hello, everyone. I am having a rather strange problem when building a dynamic query in SQL Server. I declare a variable of NVARCHAR(MAX) type, and build some queries into it, running them later with sp_executesql. One or two of these queries are so large that they surpass the 4000 char limit that, supposedly, NVARCHAR(MAX) overcomes. However, I still am having the classic problem of storing the whole query inside the variable! I use SQL Server 2008. All the documentation online I checked states that the solution is just using NVARCHAR(MAX) and the problem should not happen. How can this keep happening? Cheers, Ivo Pereira IT Consultant PortugalComputerDoc

perand type clash: nvarchar(max) is incompatible with image

in sql2005 how to add a hex string to an image field.here imageHx is image field and @ImgHex is nvarchar(max) field.i am getting error likeperand type clash: nvarchar(max) is incompatible with imageupdate #TmpCamRep set ImageHX=(@ImgHex)

Error converting data type nvarchar to numeric.

i create a form using form view tools in asp.net..when i click insert command it shows error..this is code which i use for InsertCommand:<asp:SqlDataSource ID="SqlDataSourceFormView" runat="server"         ConnectionString="<%$ ConnectionStrings:AED_PanasonicConnectionString2 %>"         SelectCommand="SELECT * FROM [Debtor]"        InsertCommand="INSERT INTO Debtor (CompanyName, Desc2, RegisterNo, Address1, Address2, Address3, Address4, PostCode)VALUES (@CompanyName, @Desc2, @RegisterNo, @Address1, @Address2, @Address3, @Address4, @PostCode)">        </asp:SqlDataSource>Error:-Error converting data type nvarchar to numeric.where i have to make changes?

Searching a NVarChar Column with multiple wildcards returns all rows

I'm building a stored procedure to return a set of records, yes nothing big. The column is an NVarchar column and I'm using a select statement of Select * from Table1 where Column1 Like @Column1 Table is currently one record containing the words:  ***Some Test Word***  Is my test word I've set the value of @Column1 to: Some - no records returned Some% - no records returned %Some% - 1 record returned  % - 1 record returned *% - no records returned %*% - 1 record returned %Not Here% - 1 record returned   Can someone tell me why if I have a leading and trailing wildcard I will get all records returned?  Does it have something to do with the '*' characters in the field because some of my users are using these characters. I've also tried changing the select to: where RTRIM(Column1) Like @Column1 with the same result and where RTRIM(Column1) Like N'%' + @Column1 with the same result   What way should I give a user the way to search for a substring inside of an NVarchar field? Oh, I tried using the Substring function and got the same result. Thanks Mike    

sql 2008 convert nvarchar to float

Hi i need to write a condition in my query where my column value is greater than 2 my column name is sales..and when ever the value in sales in greater then 2 i should get  the O/P but datatype of my  column sales is "nvarchar"  i have used the condition cast(isnull(sales,0) as float)>2, but this didnt work. if some one could help me ...

error converting nvarchar to int

i have two multivalue paramaters in a report and when I try to select more that one value for the results then i get this error when rendering the rpt both paramaters are int in the value field but I am displaying the label in the screen of the selection and passing the value as into the sproc.   it works with only one value

Error converting data type nvarchar to datetime.

hi all, I simply explain my application.plz try to understand. In my applicationi want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status and prioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?with some constant rows. am getting error in Class File near CLUser_Logged_DTClass File using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; /// <summary> /// Summary description for BalComplaints /// </summary> public class BalComplaints { public BalComplaints() { // // TODO: Add constructor logic here // } int SNo, Complaint_Type_ID, Caller_Type_ID, No_of_Articles, Article_ID, CLPriority_ID, Status_ID, Origin_ID, Destination_ID; public int SNo1 { get { return SNo; } set { SNo = value; } } public int Caller_Type_ID1 { get { return Caller_Type_ID; } set { Caller_Type_ID = value; } } public int Destination_ID1 { get { return Destination_ID; } set { Destination

SQL Server Compact 3.5 nvarchar limitation



I have a table with one column (nvarchar) with a length >127. Everything is working fine until I want to make a simple SELECT * FROM table_1, which results in error. Error message: "Object was open".

I connect to the database using ADOConnection "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5". No prob to insert more than 127 characters in the column with an INSERT INTO command. No problems to update a row. But there's just no way to make a SELECT!

Is there a fix for this... bug(?) ? Workaround? It's really annoying.

Thank you.



nvarchar(max) & SCD Transformation


Anyone has a work around for using a source field with data tye navarchar(max) with SCD transformation. I tried Casting the field as navarchar(200), but still i recieve the same error as below.

Error at DimOpportunity [Slowly Changing Dimension [6116]]: The input column "input column "description" (6912)" cannot be mapped to external column "external column "description" (6689)" because they have different data types. The Slowly Changing Dimension transform does not allow mapping between column of different types except for DT_STR and DT_WSTR.

Thank You

Text was truncated with "nvarchar(max)" data type and size by using SSIS Import and Export Wizar



I am using SSIS Import and export Wizar to load data from Excel file, I have set the datatype as "nvarchar(max); those data are not biger than 1000 bits but was failed to transfer as the error says:

[Source - TreatmentPlans$ [1]] Error: The "output column "SchoolPlan" (57)" failed because truncation occurred, and the truncation row disposition on "output column "SchoolPlan" (57)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.

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