Tag: asp.net

Can Enums in C# can be use of replacement of Lookup tables(e.g SportType,MatchType)

I have some table in database.Taking about only two 1-Sports 2-Match<> ……. In sports table there is columns SportType<br> and In Match table there is column MatchType Option 1: I have option to create SportType and MatchType Table Option 2: and second option is to crate Enums of SportType and MatchType Some people don’t prefer […]

Connecting to a remote web server and SQL database using Visual Studio

I need to set up asp.net and SQL server database hosting with a 3rd party web hosting service. To simplify the deployment process, I’d like to be able to develop the web site within a Visual Studio environment in exactly the same way as VS allows local machine or domain web sites to be edited. […]

ASP.NET Application Connection String and SQL Server Security / Permissions

I am deploying an ASP.NET application and SQL Server (2008) database on a live (production) server. The physical server is running both SQL Server 2008 and IIS 7 – it is provided by a hosting company and is not part of our internal network. I have a couple of questions regarding database security and the […]

Stored Procedure fails to see parameters or returns a convert data type error

I’ve run into a rather annoying problem which I cannot seem to get to the root of. I’ve searched the internet for similar problems – and I’ve found a few unanswered in other forums – so I thought I’d give it a go here. The following WebMethod of a webservice contacts a database, which works […]

Maintain users data integrity across multiple databases for ASP.NET

I have 2 questions. I am developing a ASP.NET web application that uses the standard ASP.NET membership. We intend to have the membership tables in 1 database. We have 2 other databases that stores data for 2 different applications. Shared – Membership info DB1 – Application1 DB2 – Application2 Both applications uses the membership info […]

Escaping user input in SQL parameters

I have the following WHERE condition in a SELECT statement: WHERE (‘.’ + column_name LIKE @prefix)) And the @prefix parameter is set as follows: cmd.Parameters.AddWithValue(“@prefix”, “%[^a-z]” & prefix & “%”) The prefix variable is taken from form input. The problem I’m having is when the user enters a ‘%’ or ‘[‘ or other special character. […]

How can I use CONTAINS() when the variable is sometimes null or empty string?

I have the following where clause: B.GivenName=@GivenFirstName) or ((@GivenFirstName = ‘””‘) or (@GivenFirstName is null)) or (B.GivenName like +’%’+ @GivenFirstName) or (B.GivenName like @GivenFirstName + ‘%’ ) or (B.GivenName like + ‘%’+ @GivenFirstName + ‘%’ ) or (CONTAINS(B.GivenName, @GivenFirstName,LANGUAGE ‘german’)) If a firstname is not entered into the search I get the error: Msg 7645, […]

nHibernate mapping with composite key and collection

I am having trouble trying to map this object that contains a collection of guids. I have the mapping working with no errors, however I keep getting empty guids inserted into OrganizationId in the OrganizationAdvertistments table. I was wondering how to map this set correctly? <?xml version=”1.0″ encoding=”utf-8″ ?> <class name=”Advertisement” table=”Advertisement” lazy=”false”> <id name=”Id”> […]

Importing excel file to SQL database, how to ignore 2nd row; asp.net & C#

I’m importing data in a SQL Server 2008 database from excel file where the first row is headers (HDR=1). The thing is that the second row is also kind of headers which i don’t really need to be imported. So how do I ignore the second row from that excel (I guess if the first […]

update table sql server fields maybe empty

I want to update a database in my asp.net application. The updated fields are set in textboxs. SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.ExecuteNonQuery(); cmd.CommandText = “update dbo.User_Info SET FirstName=@FirstName, LastName=@LastName,Degree=@Degree,Organization=@Organization,Phone=@Phone,Ext=@Ext where UserName =@username”; cmd.Parameters.Add(“FirstName”, SqlDbType.VarChar).Value = TextFirstName.Text; cmd.Parameters.Add(“LastName”, SqlDbType.VarChar).Value = TextLastName.Text; cmd.Parameters.Add(“Degree”, SqlDbType.VarChar).Value = TextDegree.Text; cmd.Parameters.Add(“Organization”, SqlDbType.VarChar).Value = TextOrg.Text; cmd.Parameters.Add(“Phone”, SqlDbType.VarChar).Value = […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.