954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Insert Dataset into SQL Database.

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!

Devin
Newbie Poster
4 posts since Dec 2004
Reputation Points: 10
Solved Threads: 0
 

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/dataadapter/dataadapter-insertcommand-sqlserver.htm

http://vb.net-informations.com/dataset/ado.net-dataset.htm

bruce

bruce2424
Newbie Poster
23 posts since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

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.

prit49
Newbie Poster
1 post since Nov 2008
Reputation Points: 10
Solved Threads: 0
 

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

sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
 

Use Format Function.
Like :

= Format(dtpicker .Value, "dd/MM/yyyy")

sierrainfo
Junior Poster
144 posts since May 2008
Reputation Points: 10
Solved Threads: 9
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You