473,320 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

iam a beginner ..pls help

when a form is taken in the .Net platform how to build a page having some connection with the SQL table in the Backend..can anyone give me an example ..pls..
Many thanks
Jan 16 '07 #1
5 1146
Frinavale
9,735 Expert Mod 8TB
when a form is taken in the .Net platform how to build a page having some connection with the SQL table in the Backend..can anyone give me an example ..pls..
Many thanks

You will have to use a the library System.Data.SqlClient.
Import this and you will be given access some objects that will let you connect to a database.

Its a lot to learn and a lot to explain so I suggest looking it up in the MSDN library online for some examples and explanations.

-Frinny
Jan 16 '07 #2
nmsreddi
366 256MB
hello

if you want to make connection with database first thing you have to do is add a

name space to your application

i.e system.data.sqlclient;(for sql server)

now you can b able to use sqlconnection used to connect to database from your

application

sqlconnection con=new sqlconnection(uid=user id for your server;pwd=;database=;server=);

now you can use your con object where ever it is needed

open connection as

con.open();

remaining ADO objects you can used as for your requirement


regards

nmsreddi
Jan 17 '07 #3
You will have to use a the library System.Data.SqlClient.
Import this and you will be given access some objects that will let you connect to a database.

Its a lot to learn and a lot to explain so I suggest looking it up in the MSDN library online for some examples and explanations.

-Frinny
many thanks for the suggestion
Jan 18 '07 #4
hello

if you want to make connection with database first thing you have to do is add a

name space to your application

i.e system.data.sqlclient;(for sql server)

now you can b able to use sqlconnection used to connect to database from your

application

sqlconnection con=new sqlconnection(uid=user id for your server;pwd=;database=;server=);

now you can use your con object where ever it is needed

open connection as

con.open();

remaining ADO objects you can used as for your requirement


regards

nmsreddi
Many Thanks for the suggestion..Actually i just started with .Net..i have made a login page with user id n password..and given two assigned fields and tried login..and then redirected to logout page..i also took register for new members and redirected to a new page..i have put some fields like name ,new user id,password and put a save button...i have written some code in the save button to bind the data in the table ..thats it..the code also is showing some errors ..not knowing how to proceed..how to save this data in the backend and how to retrieve it..i have used 4 textboxes for the data..name,surname,userid to be created and password...can u pls help me out to move furthur..they will be only few people who would like to share their knowledge..its really great on your part..many thanks once again
Jan 18 '07 #5
Frinavale
9,735 Expert Mod 8TB
Many Thanks for the suggestion..Actually i just started with .Net..i have made a login page with user id n password..and given two assigned fields and tried login..and then redirected to logout page..i also took register for new members and redirected to a new page..i have put some fields like name ,new user id,password and put a save button...i have written some code in the save button to bind the data in the table ..thats it..the code also is showing some errors ..not knowing how to proceed..how to save this data in the backend and how to retrieve it..i have used 4 textboxes for the data..name,surname,userid to be created and password...can u pls help me out to move furthur..they will be only few people who would like to share their knowledge..its really great on your part..many thanks once again

You're going to have to post the errors you get.

Here is some example code for retrieving information for a database:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         Dim dr As SqlDataReader
  3.         Dim sqlcom As New SqlCommand
  4.         Dim  dbcon As New SqlConnection(data source=nameOfSqlServer;initial catalog=NameOfDatabaseCatalog;user id=IDOfUserWithDbPermissions;password=PasswordOfUser)
  5.  
  6.         sqlcom.CommandText = "SELECT * FROM USER WHERE USER_ID=@USERID"
  7.  
  8.         'Here you have to set the paramter type to be the data type that matches your table data
  9.         sqlcom.Parameters.Add("@USERID", SqlDbType.Int).Value = 123456789
  10.  
  11.         sqlcom.CommandType = CommandType.Text
  12.         sqlcom.Connection = dbcon
  13.         If dbcon.Open() Then
  14.             Try
  15.                 dr = sqlcom.ExecuteReader
  16.                 If dr.HasRows = True Then
  17.                    'casting the information retrieved from the database into a String
  18.                    dim password as string= Ctype(dr("password),String)
  19.                 Else
  20.                     'No Rows Returned From Read...UserID Doesn't Exist
  21.                 End If
  22.                 dr.Close()
  23.             Catch ex As Exception
  24.             End Try
  25.         End If
  26.  
Here is an example of storing into the database:
Expand|Select|Wrap|Line Numbers
  1.         Dim sqlcom As New SqlCommand
  2.         Dim  dbcon As New SqlConnection(data source=nameOfSqlServer;initial catalog=NameOfDatabaseCatalog;user id=IDOfUserWithDbPermissions;password=PasswordOfUser)
  3.         sqlcom.CommandText = "INSERT INTO  USER " + _
  4.                         "(USER_ID,PASSWORD) " + _
  5.                         "VALUES('"+1234567890+"','"+"password"+"')"
  6.         sqlcom.CommandType = CommandType.Text
  7.         sqlcom.Connection = dbcon
  8.  
  9.          If dbcon.Open() Then
  10.              Try
  11.                  sqlcom.ExecuteNonQuery()
  12.              Catch ex As Exception
  13.              End Try
  14.           End If
  15.  
Hope this helps you

-Frinny
Jan 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Art | last post by:
NEWBIE ALERT! Esteemed List Participants and Lurkers: (System: P-II 350, 192 meg, Win98 SE, Python 2.2.3, wxPythonWIN32-2.4.1.2-Py22.exe) I'm having a lot of fun getting started with Python...
3
by: jvax | last post by:
Hi all, I hope I'm posting in the right NG... I have a data text file I want to read from a c++ program. the data file goes like this: 90 # number of balls 33 42 13
8
by: Grrrbau | last post by:
I'm a beginner. I'm looking for a good C++ book. Someone told me about Lafore's "Object-Oriented Programming in C++". What do you think? Grrrbau
1
by: LRW | last post by:
I was wondering if anyone could recommend some good beginner sites and tutorial sites for writting ASP.Net pages in C#. Things that especially help with datagrids!! And, are there additional...
14
by: z_learning_tester | last post by:
But I can't seem to find the answer. The question is how do you reverse the words in a string? Or how do you reverse the numbers listed in a string? The example is usually something like: Turn...
3
by: William Foster | last post by:
Good evening all, Microsoft is really starting to annoy me as a new user. I am trying to convert my code from VBA (A very user friendly laguage with generally good help files) to Visual Studio...
10
by: See_Red_Run | last post by:
Hi, I am trying to figure out how to get started with PHP/MySQL. Everything I've read so far says to start with PHP first. I was expecting something like Visual Basic Express or some other type...
1
by: Blue_hatter | last post by:
Hey Guys, I'm a newbie to the whole C++ Programming thing as I think I said before in a post. The thing is, I have this idea that might help me to learn at a better pace than I am doing currently....
10
by: hamza612 | last post by:
I want to start learning how to program. But I dont know where to start. From what I've heard so far c++ is not a good lang. to learn as a beginner because its very complicated compared to others...
22
by: ddg_linux | last post by:
I have been reading about and doing a lot of php code examples from books but now I find myself wanting to do something practical with some of the skills that I have learned. I am a beginner php...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.