Showing posts with label input. Show all posts
Showing posts with label input. 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

Monday, March 19, 2012

A syntex problem.....I think

Have a SQL paramater query running in VBA. Fails on the line that requests information. The problem is the brackets [] that are used to input data to make the query operate between certain limits. I used Between [enter x] and [enter y] which does not work in VBA. If I use Between #01/01/2004# and #07/30/2004# it works with the fixed data. The query works just fine in the normal Access 2000 gui but not in VBA.
Can anybody help with this problem. I have looked high and low but find everything else but what to do with the brackets in a SQL VBA application.
Thanks,
DonThe use of brackets in a query is an MS-Access specific feature... VBA doesn't directly support that functionality. You will have to code the parameter entry screen and build the query in VBA.

-PatP

Tuesday, March 6, 2012

a SELECT statment, please help me

hello,

i have a page "Picture.aspx?PictureID=4"

i have a FormView witch shows details about that picture and uses a stored procedure with input parameter the "@.PictureID" token from query string

the Pictures table has among other rows "PictureID", "UserID" - uniqueidentifier - from witch user the picture belongs to

i have a second FormView on the same page, witch should show "other pictures from the same user" and uses a Stored Procedure

how should i write that stored procedure...frist to take the UserID from the picture with PictureID=4, then to pass it as input parameter and select the pictures witch has as owner the user with that UserID, and if can be done, to avoid showing the PictureID=4 again

a solution should be to add at querry the UserID too, but i want to avoid that

any sugestion is welcomed, please help me

THANKS

CREATE PROCEDURE GetPictures
@.UserId uniqueidentifier,
@.DisplayedPictureId int
AS
BEGIN
SELECT * FROM Pictures
WHERE UserId = @.UserId AND PictureID <> @.DisplayedPictureId
END

|||

hey, thanks for code

the DisplayedPictureId i take it from querry string, but how should i take the UserId trying to avoid puting it on querry string too

i heard something about Sesion or Cookie, is it good, but how should i use that?

|||

If you are using asp.net membership you can use Membership.GetUser().ProviderUserKey.ToString() to get UserId for logged in users.

|||

yes, but a visitor is not the "owner" of the picture...and the page is public to anonymous visitors too

|||

hey, i figured out how to do that

i save the UserId in a hiddenField (from the first formView) and then i use it as input parameter to second formView

thanks for help

Sunday, February 19, 2012

A problem with SQLColumns call

Hello,
let us consider the following problem with SQLColumns call. Fist of all here goes a small quote from MSDN on SQLColumns input string parameters:

CatalogName [Input]
Catalog name. If a driver supports catalogs for some tables but not for others, such as when the driver retrieves data from different DBMSs, an empty string ("") denotes those tables that do not have catalogs.

I read it as I can call SQLColumns the following ways:
SQLColumns(hstmt_, (SQLCHAR *)"",SQL_NTS, ...
or
SQLColumns(hstmt_, (SQLCHAR *)"",0, ...

but none of this calls works. The only working way is

SQLColumns(hstmt_, 0,0, ...

Please, note that all calls work for non-Microsoft ODBC drivers I have tried.

So, I believe there is a bug either in MS ODBC driver implementation or in MSDN.

--
Michael Kochetkov

Unfortunately, some implementation details are driver-specific. For the Microsoft ODBC drivers, when you specify the name as "", SQLColumns looks for all tables with that name. Since no tables have a name of "", it returns no results.

If you specify 'NULL' for a table name, it will look for ALL tables.

You may need to wrap your queries based on Driver Name, such as

if(<< MS Driver >>)

SQLColumns(hstmt, NULL, 0, ...)

else

SQLColumns(hstmt, "", SQL_NTS, ...)

|||

> Unfortunately, some implementation details are driver-specific.
I have just wanted to point out that there is a bug: either in MS implementation or MSDN. Let us get back to the CatalogName parameter description. I believe the following statement "an empty string ("") denotes those tables that do not have catalogs." shall be replaced with something like this: as far as MS ODBC driver does distinguish between SQL Nulls and empty strings ("") you cannot use empty string to denote that tables do not have catalogs and are to use 0 that stands for SQL Null value inside.

--
Michael Kochetkov

P.S. Edited: tables have --> tables do not have