Showing posts with label base. Show all posts
Showing posts with label base. Show all posts

Sunday, March 25, 2012

a webpage that directly inputs data to a specific table in an sql database ?

im new to sql and ive created a test data base with a test table having 3 input fields i was wondering if it was possible to use a webpage to input data into the database in a specific table
ive seen some net articles discussing this but as i said im new they talked about using an asp page,so i was wondering if someone could help me out with a simple code to enable a webpage to input data on an sql table
so how do i go about it ?
test_database
dbo.test_table
the 3 input fields are name age gender

ive also set an odbc for the data base (test_database) set at native

tnx

Quote:

Originally Posted by arawsg

im new to sql and ive created a test data base with a test table having 3 input fields i was wondering if it was possible to use a webpage to input data into the database in a specific table
ive seen some net articles discussing this but as i said im new they talked about using an asp page,so i was wondering if someone could help me out with a simple code to enable a webpage to input data on an sql table
so how do i go about it ?
test_database
dbo.test_table
the 3 input fields are name age gender

ive also set an odbc for the data base (test_database) set at native

tnx


Hi ,

I don't know which platform you are using to develop your webpage.I give you sample code here to insert data into a sql server database table from an asp.net web page. I think this will help you.

---------
Using System.Data.SqlClient
void Page_Load()
{
SqlConnection con=new SqlConnection ("server=labserver;database=testdb;username=sa;passw ord=s");
SqlCommand cmd=new SqlCommand("insert into emptable(empid,empname) values(2312,'Adam')",con);
con.open();
cmd.ExecuteNonQuery();
con.close();
}
----------|||

Quote:

Originally Posted by balajiu

Hi ,

I don't know which platform you are using to develop your webpage.I give you sample code here to insert data into a sql server database table from an asp.net web page. I think this will help you.

---------
Using System.Data.SqlClient
void Page_Load()
{
SqlConnection con=new SqlConnection ("server=labserver;database=testdb;username=sa;passw ord=s");
SqlCommand cmd=new SqlCommand("insert into emptable(empid,empname) values(2312,'Adam')",con);
con.open();
cmd.ExecuteNonQuery();
con.close();
}
----------


tnx ill try your code out

Friday, February 24, 2012

A question about clustered indexes forcing rebuild of non-clustered indexes.

So I'm readinghttp://www.sql-server-performance.com/tips/clustered_indexes_p2.aspx and I come across this:

When selecting a column to base your clustered index on, try toavoid columns that are frequently updated. Every time that a column used for a clustered index is modified, all of the non-clustered indexes must also be updated, creating additional overhead. [6.5, 7.0, 2000, 2005]Updated 3-5-2004

Does this mean if I have say a table called Item with a clustered index on a column in it called itemaddeddate, and several non-clustered indexes associated with that table, that if a record gets modified and it's itemaddeddate value changes, that ALL my indexes on that table will get rebuilt? Or is it referring to the table structure changing?

If so does this "pseudocode" example also cause this to occur:

sqlstring="select * from item where itemid=12345"

rs.open sqlstring, etc, etc, etc

rs.Fields("ItemName")="My New Item Name"

rs.Fields("ItemPrice")=1.00

rs.Update

Note I didn't explicitly change the value of rs.fields("ItemAddedDate")...does rs.Fields("ItemAddedDate")=rs.Fields("ItemAddedDate") occur implicitly, which would force the rebuild of all the non-clustered indexes?

Since it's been a while and no one responded, I thought I'd throw my 2 cents in. I'm not sure the link you posted is correct, but it might be. It would depend on whether SQL Server attempts to maintain clustering when you update a clustered index, and I don't know the answer to that. For example, suppose you have a clustered index on name and update someone from "AAAA" to "ZZZZ". This would change his position in the table, which is to say it would change the page number of that row (since it would move from the beginning of the DB to the end), which would mean that all other indexes would have to be updated too.

This depends entirely on whether SQL actually tries to maintain the clustering in real time, and I don't know the answer to that. With other products I've worked with, the DB just lets the data get out of cluster and you have to rebuild them from time-to-time.

|||

I posted this question on sql-server-performance and got a reply:http://sql-server-performance.com/Community/forums/p/23274/132088.aspx#132088

|||

dbland07666:

I posted this question on sql-server-performance and got a reply:http://sql-server-performance.com/Community/forums/p/23274/132088.aspx#132088

And that would be me ..Smile

|||

I figured!