Showing posts with label allows. Show all posts
Showing posts with label allows. Show all posts

Friday, March 30, 2012

Information Wont Post To My Database

I'm having a weird problem with an easy process. I have a section that allows people to enter their name and email address if they wish to be contacted. I have it set up so that when they enter that information into the text boxes, the info is then sent to my SQL database. The code looks right to me, but it never comes up. Here is the code I have for the button_click.

Dim

NTAdatasourceAsNew SqlDataSource()

NTAdatasource.ConnectionString = ConfigurationManager.ConnectionStrings(

"DatabaseConnectionString1").ToString()

NTAdatasource.InsertCommandType = SqlDataSourceCommandType.Text

NTAdatasource.InsertCommand =

"INSERT into ContactUs (YourName, EmailAddress, DateTimeStamp) VALUES (@.YourName, @.EmailAddress, @.DateTimeStamp)"

NTAdatasource.InsertParameters.Add(

"YourName", txtYourName.Text)

NTAdatasource.InsertParameters.Add(

"EmailAddress", txtEmailAddress.Text)

NTAdatasource.InsertParameters.Add(

"DateTimeStamp", DateTime.Now)Dim RowsAddedAsInteger = 0Try

RowsAdded = NTAdatabase.Insert()

Catch exAs Exception

Server.Transfer(

"problem.aspx")EndTry

If RowsAdded <> 1Then

Server.Transfer(

"problem.aspx")Else

Server.Transfer(

"success.aspx")EndIf

EndSub

The strange thing is that when I debug, the "rowsadded" value comes up to 1. The process runs through debugging just fine and redirects me to my "success.aspx" page. What am I doing wrong?

Thanks

Never mind...figured it out.

Monday, March 12, 2012

Indexing ?

I have a simple table that includes an ID and 8 user-defined data fields. Th
e
fields are nvarchar(255) and the application allows the user to store any
data they like in them. The application also allows searching on any
combination of up to 5 of the fields, with an AND or OR logical combination.
The query returns the result set unordered.
Does anyone have any thoughts on an indexing scheme for this situation? I'm
not quite sure what is best given that the user may search on any combinatio
n
of fields. Some obvious thoughts are:
1. An separate index on each column.
2. A single index covering all columns.
3. A separate index on each of the 8 choose 5 combinations of columns
(whoah!).
Any thoughts?Although I do not condone this, creating an index on each of the columns
would allow SQL Server to use Index Joining / Intersection to perform the
search. Creating an Index on all the columns would only benefit the
statements that search on the columns in the order of the index.
"Ken" wrote:

> I have a simple table that includes an ID and 8 user-defined data fields.
The
> fields are nvarchar(255) and the application allows the user to store any
> data they like in them. The application also allows searching on any
> combination of up to 5 of the fields, with an AND or OR logical combinatio
n.
> The query returns the result set unordered.
> Does anyone have any thoughts on an indexing scheme for this situation? I'
m
> not quite sure what is best given that the user may search on any combinat
ion
> of fields. Some obvious thoughts are:
> 1. An separate index on each column.
> 2. A single index covering all columns.
> 3. A separate index on each of the 8 choose 5 combinations of columns
> (whoah!).
> Any thoughts?
>