ADO.NET :: Checking Mssql For Existing String?
Feb 23, 2011i want to make so i can check if the string already exists in a row in my table in the mssql from my application with c#.
View 4 Repliesi want to make so i can check if the string already exists in a row in my table in the mssql from my application with c#.
View 4 RepliesI am creating a custom control and had a thought before I began. My control relies on the jQuery library to work. What if the user already has a version of the library already on their page. Will this effect anything? If my version is newer / older and my control will only work with that version of the libaray, what should I do?
View 1 RepliesI'm having trouble with an SQL statement. I want to have one statement that checks to see if it a record exists. If it does, then update it and if it doesnt then insert a new one in the server. Here is what I have so far:
[Code]....
To Add new row to a dataset table, I am using code below. Before adding this how do I check if that row has already been added to the dataset?
Example:
Dim newCustomersRow As DataRow = DataSet1.Tables("Customers").NewRow()
newCustomersRow("CustomerID") = "ALFKI"
newCustomersRow("CompanyName") = "Alfreds Futterkiste"
DataSet1.Tables("Customers").Rows.Add(newCustomersRow)
Note: The table I am dealing with does not contain a primary key!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True")
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT * FROM Table1 WHERE Date =" & TextBox1.Text & "'", SQLData)
SQLData.Open()
Dim dtrReader As System.Data.SqlClient.SqlDataReader = cmdSelect.ExecuteReader()
While dtrReader.Read()
For j As Integer = 1 To 31
Dim s As String = "s" & j
If dtrReader(s.ToString()).ToString() = "b" Then
Dim img As ImageButton = DirectCast(Panel1.FindControl(s.ToString()), ImageButton)
img.ImageUrl = "~/Images/booked.gif"
img.Enabled = False
End If
Next
End While
dtrReader.Close()
SQLData.Close()
End Sub
Error:
Unclosed quotation mark after the character string ''.
i am trying to create a temporary table as like an existing table.
create table #tmp AS ( select Table1.* from Table1 where Table1.column name in (select Table2.column name from Table2 where conditions) )
But it is showing Error...
What's the regular expression to check if a string starts with "mailto" or "ftp" or "joe" or...
Now I am using C# and code like this in a big if with many ors:
String.StartsWith("mailto:")
String.StartsWith("ftp")
It looks like a regex would be better for this. Or is there a C# way I am missing here?
I have got a function as below to check user whether input text is a legal words or not , but this function would trim or replace the bad words from input string.
Therefore i just want to match input string in this method (don't want to trim or replace). If it matched with any of these then should throw a message "Special characters not allowed"
Function remove_bad_words(ByVal stringword As String) As String
stringword = stringword.ToUpper
Dim newChars As String
Dim badstuff() As String = {
[Code] ....
I am using Html.ActionLink<Controller>(p => p.Action(), "action link") syntax for generating urls in views.In one of the cases I need to attach the existing query string from the url. How would you recommend doing this?
View 2 RepliesI have a label with a text property which needs to bet set from a resource file.
This actually works ok: Text='<%$ Resources:TextResources, WebsiteTitle %>'
However I want to do something like:
Text='Welcome to <%$ Resources:TextResources, WebsiteTitle %>. Register here'.
However this doesn't work.
I'm running into a really annoying problem with my Linq to SQL project. When I add everything in under the web project everything goes as expected and I can tell it to use my existing connection string stored in the web.config file and the Linq code pulls directly from the ConfigurationManager.
This all turns ugly once I move the code into its own project. I've created an app.config file, put the connection string in there as it was in the web.config but when I try to add another table in the IDE keeps forcing me to either hardcode the connection string or creates a Settings file and puts it in there, which then adds a new entry into the app.config file with a new name.
Is there a way keep my Linq code in its own project yet still refer back to my config file without the IDE continuously hardcoding the connection string or creating the Settings file? I'm converting part of my DAL over to use Linq to SQL so I'd like to use the existing connection string that our old code is using as well as keep the value in a common location, and one spot, instead of in a number of spots.
Manually changing the mode to WebSettings instead of AppSettings works untill I try to add a new table, then it goes back to hardcoding the value or recreating the Settings file. I also tried to switch the project type to be a web project and then rename my app.config to web.config and then everything works as I'd like it to. I'm just not sure if there are any downfalls to keeping this as a web project since it really isn't one. The project only contains the Linq to SQL code and an implementation of my repository classes.
My project layout looks like this
[code]....
Every time I try to make the default constructor look like the first way, it always auto changes back to the second way once I make a change to the file unless the DBML is inside of a web project.
I am about to get my sites hosted with a local host company. They are offering me their lowest cost MSSQL server, which is the web edition. So my question is what is the difference between that and 2008 express edition? Can express edition be used for a full fledge in production website? And does Web implies that I will be interacting with it via the web correct. Lastly, if the web version is not chosen what is the typical protocol for uploading and maintaining a site when you have a dedicated server. Do you normally have to go to the data center or is there like a web portal that can be used. I will be asking the guys at the company these questions as well, but I want to make sure I get another opinion on the issue.
View 1 RepliesI have two user controls that need to add a class atribute to the body tag of my page, however they currently over write one another if I just use
Body.Attributes.Add("class","value")
So I need to check if the class attribute exsists and if it already contains the value Im going to add.
If Not Body.Attributes("class").Contains("value") Then
Body.Attributes.add("class", Body.Attributes("class") + " " + "value")
End If
I have a database which stores .png images as the sql "image" type. I have some code which retrieves these images as a byte[], and sends them to the page via the FileContentResult object in .Net. Performance is key in this application, and the images have to be retrieved and displayed as quickly as possible. My question is, can this operation be performed quicker by passing a byte stream from the database to the browser, and not at anytime storing the whole byte array in memory. If this is possible and worthwhile doing, how do I do it?
Here is the code I have so far:
[code]....
I would like to know how i can take a backup of my database to .bak file on my pc using asp.net code?
View 8 RepliesIs it possible to create a wap having a mssql connection?
View 1 RepliesI asked plesk the following question:I've been through the documentation and scoured various forums, but I can't find a defintive guide to uploading an mssql db (contained in a app_data folder) to the server and conecting it via the Plesk control panel. I've created a db and user via the panel but how do I get the actual db to the server and get it to work?"and they replied:"For database restoration please upload your database backup file ( i.e. .bak ) under your hosting space and update us the exact path where you place this file + your database login details ( i.e. database name , database user name and password ). So we restore this database for you. "
View 3 RepliesI often hear the term database driven web app and just wanted to make sure using that description is the most accurate when describing an asp.net web app that relies on an SQL Database for all of its dynamic information.
What specifically is the correct terminology.
I have created a C# registration page that includes a secret question and answer. The secret questions are in a dropdown list. When the form is submitted, all field information gets written to my mssql database successfully but the value selected in the dropdown ListItem gets NULL inserted instead of the question.
What am I missing? Here is my code.
[Code]....
This may not the best place for this question, but I'm going to give it a shot. I have a large (3GB) file that contains maybe 100 fields, CSV. ALL FIELDS are surrounded by double quotes, a standard CSV file. So, it looks like this:
"12345678", "SMITH", "JOHN", "GARLAND, TEXAS", "75043","","","","37" (and so on)
I need to import this into SQL server but have been unable to find any simple way of doing so using the BULK INSERT. I could obviously do it with some coding [a lot, given the number of fields] but one would think a product like MSSQL would have this most basic of functionality built in.
i want to know how to retrieve data from database to label and store text box data into data base
View 3 RepliesHows does one move viewstate to the MSSQL 2005 server? Asp.net 2.0 Ajax project.
Can it be only done for a single aspx page or a group of pages, of does it have to be the whole application?
How do I import this XML: [URL] into MSSQL?
View 5 Repliesmy question is that i actually want to make a table in a database and update delete the recordsin that table The thing is that i dont want to make the database table in the sql server but i want to make it in the visual web developer (the editor i am using) can any body gimme any idea abt how i can do this orany link regarding to this
View 11 RepliesI was wondering what you guys thinks is the most efficient way to select data from a msSQL database.. I tend to use a sqldatareader, but is this really the best way? - It is particularly impractical if one also must take into account, that the table may be "Null"?:
[Code]....
[Code]....