Wrox Programmer Forums
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 2nd, 2009, 07:37 AM
Registered User
 
Join Date: Mar 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO(insert+select )with vb.net

the folowing code for insert to data base\\\\\\\\\\\\\\\\\\\
Dim mycon As SqlConnection = New SqlConnection("Data Source=alfc1ec8201d02;Initial Catalog=tajer;Integrated Security=SSPI")
Dim com As SqlCommand = New SqlCommand("insert into add_product values(@sn,@product_****,@product_type,@price)", mycon)
mycon.Open()
com.Parameters.AddWithValue("@sn", 1)
com.Parameters.AddWithValue("@product_****", TextBox1.Text)
com.Parameters.AddWithValue("@product_type", ComboBox1.Text)
com.Parameters.AddWithValue("@price", Convert.ToInt32(TextBox2.Text))
Dim x AsInteger = com.ExecuteNonQuery
If x = 1 Then
MsgBox("add complet")
TextBox1.Clear()
TextBox2.Clear()


EndIf
the folowing code for insert to data base select\\\\\\\\\\\\\\\\\
Dim con As SqlConnection = New SqlConnection("Data Source=al-fc1ec8201d02;Initial Catalog=tajer;Integrated Security=SSPI")
Dim cmd As SqlCommand = New SqlCommand("select product_****,product_type from add_product ", con)
con.Open()
Dim dr As SqlDataReader = cmd.ExecuteReader
While dr.Read
ComboBox1.Items.Add(dr.GetValue(0) & " " & dr.GetValue(1))
EndWhile

Last edited by haytham tahrawi; March 2nd, 2009 at 03:27 PM..
 
Old March 2nd, 2009, 02:14 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample code needed for Professional ADO.NET with VB .NET hughveal ADO.NET 21 July 9th, 2009 03:06 AM
DB insert, VB.NET MDM ASP.NET 2.0 Basics 1 June 29th, 2006 06:14 PM
VB.net and SQL select skicrud VB.NET 1 November 4th, 2004 07:02 AM
How can connect VB.Net with ADO.Net? arvind_pathak VS.NET 2002/2003 1 November 6th, 2003 09:22 AM
MSDE and SQL CE (using VB.NET and ADO.NET) LEGS ADO.NET 0 July 12th, 2003 11:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.