HighTechTalks DotNet Forums  

How to insert a record

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss How to insert a record in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rajani
 
Posts: n/a

Default How to insert a record - 04-03-2006 , 10:05 PM






Hello,

I am new to ASP.NET. I have a table(users) in the database.
I placed two textboxes on the webform(txtUID, txtUName)

how can i insert this values to my users table.

like ... "insert into users(userid,username) values('" & txtUID.text & "','"
& txtUName.text & "')"

how can i execute this query?

thanks in advance

Reply With Quote
  #2  
Old   
Mangesh
 
Posts: n/a

Default RE: How to insert a record - 04-04-2006 , 01:41 AM






Hi,
Hoping that you want to submit data to the SQL Server, i am giving you a
sample code. Please refer it and read relative topics from MSDN too

like try- catch for error capturing etc.

Dim conn As New SqlConnection

conn.ConnectionString = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=DBName;Data Source=localhost"

conn.Open()

Dim cmd As New SqlCommand

cmd.Connection = conn

cmd.CommandText = "insert into users(userid,username) values('" &
txtUID.text & "','" & txtUName.text & "')"

cmd.ExecuteNonQuery()

conn.Close()

Thanks & Regards,
Mangesh

"Rajani" wrote:

Quote:
Hello,

I am new to ASP.NET. I have a table(users) in the database.
I placed two textboxes on the webform(txtUID, txtUName)

how can i insert this values to my users table.

like ... "insert into users(userid,username) values('" & txtUID.text & "','"
& txtUName.text & "')"

how can i execute this query?

thanks in advance
"Rajani" wrote:

Quote:
Hello,

I am new to ASP.NET. I have a table(users) in the database.
I placed two textboxes on the webform(txtUID, txtUName)

how can i insert this values to my users table.

like ... "insert into users(userid,username) values('" & txtUID.text & "','"
& txtUName.text & "')"

how can i execute this query?

thanks in advance

Reply With Quote
  #3  
Old   
Ken
 
Posts: n/a

Default RE: How to insert a record - 04-27-2006 , 05:45 PM



I'll offer some advice based on experience. You want to avoid such dynamic
text queries as much as possible. I recommend learning stored procedures and
looking up SQL Injection to learn of the security hazards of dynamic text
queries.

"Rajani" wrote:

Quote:
Hello,

I am new to ASP.NET. I have a table(users) in the database.
I placed two textboxes on the webform(txtUID, txtUName)

how can i insert this values to my users table.

like ... "insert into users(userid,username) values('" & txtUID.text & "','"
& txtUName.text & "')"

how can i execute this query?

thanks in advance

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.