943,518 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 75744
  • VB.NET RSS
Dec 22nd, 2004
0

Insert Dataset into SQL Database.

Expand Post »
Okay heres the dilemna....

I have a Dataset("LineItems") that Stores information about so many records.

To source to this DataSet("LineItems") is not its intended ouput.

Meaning I pull this info in from one database and output to another.

My problem is i have no idea on how to write an insert statement that will insert multiple records into a SQL table. Does anyone have any pointers????

PLEASE HELP ASAP. THANKS!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Devin is offline Offline
4 posts
since Dec 2004
Nov 8th, 2008
0

Re: Insert Dataset into SQL Database.

for int i=0 to dataset.tables(0).rows.count -1
adapter.InsertCommand = New SqlCommand(insertSQL, connection)
adapter.InsertCommand.ExecuteNonQuery()
next i

http://vb.net-informations.com/dataa...-sqlserver.htm

http://vb.net-informations.com/datas...et-dataset.htm

bruce
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bruce2424 is offline Offline
23 posts
since Jun 2008
Nov 9th, 2008
0

Re: Insert Dataset into SQL Database.

in a form , I set dtpicker ( date calender ) , it is ok, i choose a date ( dd/mm/yyyy) format ( 15 /10/2008 ) , when it save in database field , it say wrong . i want my all date field will save and retrieve ( when modify ) in (dd/mm/yyyy) format. how is it possible.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
prit49 is offline Offline
1 posts
since Nov 2008
Nov 18th, 2008
0

Re: Insert Dataset into SQL Database.

Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connetionString As String
Dim connection As SqlConnection
Dim adapter As New SqlDataAdapter
Dim sql As String
connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"
connection = New SqlConnection(connetionString)
sql = "insert into product (Product_id,Product_name,Product_price) values(7,'Product7',700)"
Try
connection.Open()
adapter.InsertCommand = New SqlCommand(sql, connection)
adapter.InsertCommand.ExecuteNonQuery()
MsgBox("Row inserted !! ")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008
Nov 18th, 2008
0

Re: Insert Dataset into SQL Database.

Use Format Function.
Like :

= Format(dtpicker .Value, "dd/MM/yyyy")
Reputation Points: 10
Solved Threads: 9
Junior Poster
sierrainfo is offline Offline
144 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Installation help
Next Thread in VB.NET Forum Timeline: Select Case Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC