Click here to Skip to main content
15,904,935 members
Home / Discussions / Database
   

Database

 
GeneralDatabase Load COmmand Pin
asv10-Jun-04 8:33
asv10-Jun-04 8:33 
GeneralRe: Database Load COmmand Pin
Chris Meech10-Jun-04 9:07
Chris Meech10-Jun-04 9:07 
GeneralRe: Database Load COmmand Pin
Anonymous11-Jun-04 9:51
Anonymous11-Jun-04 9:51 
GeneralDefault name Pin
Small Rat10-Jun-04 7:33
Small Rat10-Jun-04 7:33 
GeneralTransferring data from dbaseIII+ to SQLSvr2000/Access Pin
sanjaysagrawal10-Jun-04 1:51
sanjaysagrawal10-Jun-04 1:51 
GeneralRecord No. Pin
Tuwing.Sabado9-Jun-04 20:56
Tuwing.Sabado9-Jun-04 20:56 
GeneralRe: Record No. Pin
Hesham Amin9-Jun-04 21:30
Hesham Amin9-Jun-04 21:30 
Generalupdate sql server table with dataset from excel Pin
Anonymous9-Jun-04 4:00
Anonymous9-Jun-04 4:00 
I have a program that imports data from an excel spreadsheet into a dataset. I then create a connection to sql server and check to see if a table exist, drop it and recreate it. I cant figure out how to poulate the newly create sql server table with the dataset from excel. any help would be great. Here is the code:

Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TabControl1 As System.Windows.Forms.TabControl
Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Friend WithEvents TabPage1 As System.Windows.Forms.TabPage
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents TabPage2 As System.Windows.Forms.TabPage
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents DataGrid1 As System.Windows.Forms.DataGrid
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.TabControl1 = New System.Windows.Forms.TabControl()
Me.TabPage1 = New System.Windows.Forms.TabPage()
Me.Button2 = New System.Windows.Forms.Button()
Me.Button1 = New System.Windows.Forms.Button()
Me.TabPage2 = New System.Windows.Forms.TabPage()
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar()
Me.DataGrid1 = New System.Windows.Forms.DataGrid()
Me.TabControl1.SuspendLayout()
Me.TabPage1.SuspendLayout()
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'TabControl1
'
Me.TabControl1.Controls.AddRange(New System.Windows.Forms.Control() {Me.TabPage1, Me.TabPage2})
Me.TabControl1.Location = New System.Drawing.Point(8, 40)
Me.TabControl1.Name = "TabControl1"
Me.TabControl1.SelectedIndex = 0
Me.TabControl1.Size = New System.Drawing.Size(544, 360)
Me.TabControl1.TabIndex = 3
'
'TabPage1
'
Me.TabPage1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.Button1})
Me.TabPage1.Location = New System.Drawing.Point(4, 22)
Me.TabPage1.Name = "TabPage1"
Me.TabPage1.Size = New System.Drawing.Size(536, 334)
Me.TabPage1.TabIndex = 0
Me.TabPage1.Text = "Step 1 - Import EDI"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(8, 40)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(136, 24)
Me.Button2.TabIndex = 6
Me.Button2.Text = "Transfer EDI to Visual"
Me.Button2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'Button1
'
Me.Button1.AccessibleDescription = ""
Me.Button1.Cursor = System.Windows.Forms.Cursors.Hand
Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Bitmap)
Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight
Me.Button1.Location = New System.Drawing.Point(8, 8)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(136, 24)
Me.Button1.TabIndex = 0
Me.Button1.Tag = ""
Me.Button1.Text = "Load EDI from Deere"
Me.Button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'TabPage2
'
Me.TabPage2.Location = New System.Drawing.Point(4, 22)
Me.TabPage2.Name = "TabPage2"
Me.TabPage2.Size = New System.Drawing.Size(536, 334)
Me.TabPage2.TabIndex = 1
Me.TabPage2.Text = "Step 2 - Compare Data"
'
'ProgressBar1
'
Me.ProgressBar1.Location = New System.Drawing.Point(416, 16)
Me.ProgressBar1.Name = "ProgressBar1"
Me.ProgressBar1.Size = New System.Drawing.Size(136, 13)
Me.ProgressBar1.TabIndex = 4
'
'DataGrid1
'
Me.DataGrid1.CaptionForeColor = System.Drawing.Color.Yellow
Me.DataGrid1.DataMember = ""
Me.DataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
Me.DataGrid1.Location = New System.Drawing.Point(16, 136)
Me.DataGrid1.Name = "DataGrid1"
Me.DataGrid1.Size = New System.Drawing.Size(528, 256)
Me.DataGrid1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(560, 405)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.DataGrid1, Me.TabControl1, Me.ProgressBar1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.TabControl1.ResumeLayout(False)
Me.TabPage1.ResumeLayout(False)
CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub

#End Region


Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

' Create connection string variable for excel.
Dim a As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=c:\supplier requirements.xls;" _
& "Extended Properties=Excel 8.0;"

' Create the connection object by using the preceding connection string.
Dim objConn As New OleDbConnection(a)
' Open connection with the database.
objConn.Open()
' The code to follow uses a SQL SELECT command to display the data from the worksheet.
' Create new OleDbCommand to return data from worksheet.
Dim objCmdSelect As New OleDbCommand("Select * from [supplier requirements$]", objConn)
' Create new OleDbDataAdapter that is used to build a DataSet
' based on the preceding SQL SELECT statement.
Dim objAdapter As New OleDbDataAdapter()
' Pass the Select command to the adapter.
objAdapter.SelectCommand = objCmdSelect
' Create new DataSet to hold information from the worksheet.
Dim objDataset As New DataSet()
' Fill the DataSet with the information from the worksheet.
objAdapter.AcceptChangesDuringFill = False
objAdapter.Fill(objDataset, "XLData")
' Build a table from the original data.
DataGrid1.DataSource = objDataset.Tables(0).DefaultView

'get row count

Dim rows As DataRow()
Dim numberofrows As Integer
rows = objDataset.Tables(0).Select()
numberofrows = rows.Length

Me.DataGrid1.CaptionText = CStr(numberofrows) + " rows succesfully loaded into dataset."

Dim SQLConnection As New System.Data.SqlClient.SqlConnection()
SQLConnection.ConnectionString = "user id=sa; password=sa; initial catalog=akgpilot; server=akg-chris-l\vsdotnet;"
SQLConnection.Open()

Dim sqlString As String = "If exists (SELECT name FROM sysobjects WHERE name = N'JD_EDI' AND type = 'U') DROP TABLE JD_EDI"
Dim sqlString2 As String = "Create Table JD_EDI (Type varchar)"

Dim sqlStringCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(sqlString, SQLConnection)
sqlStringCommand.ExecuteNonQuery()

Dim sqlStringCommand2 As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(sqlString2, SQLConnection)
sqlStringCommand2.ExecuteNonQuery()
Generaldelete/modify stored procedure Pin
sharonz9-Jun-04 2:44
sharonz9-Jun-04 2:44 
GeneralRe: delete/modify stored procedure Pin
Michael Potter9-Jun-04 6:13
Michael Potter9-Jun-04 6:13 
GeneralRe: delete/modify stored procedure Pin
Edbert P9-Jun-04 20:02
Edbert P9-Jun-04 20:02 
GeneralRe: delete/modify stored procedure Pin
sharonz9-Jun-04 20:22
sharonz9-Jun-04 20:22 
GeneralRe: delete/modify stored procedure Pin
Edbert P9-Jun-04 20:32
Edbert P9-Jun-04 20:32 
GeneralRe: delete/modify stored procedure Pin
sharonz9-Jun-04 20:50
sharonz9-Jun-04 20:50 
GeneralT-SQL for backing up database with current Datetime Pin
Raybot8-Jun-04 23:55
Raybot8-Jun-04 23:55 
GeneralRe: T-SQL for backing up database with current Datetime Pin
RichardGrimmer9-Jun-04 1:30
RichardGrimmer9-Jun-04 1:30 
GeneralRe: T-SQL for backing up database with current Datetime Pin
Michael Potter9-Jun-04 6:17
Michael Potter9-Jun-04 6:17 
GeneralRe: T-SQL for backing up database with current Datetime Pin
Grimolfr9-Jun-04 9:39
Grimolfr9-Jun-04 9:39 
GeneralRe: T-SQL for backing up database with current Datetime Pin
Raybot9-Jun-04 20:58
Raybot9-Jun-04 20:58 
QuestionHow to get list of SQL servers on network ? Pin
vgrigor18-Jun-04 22:55
vgrigor18-Jun-04 22:55 
AnswerRe: How to get list of SQL servers on network ? Pin
Hesham Amin9-Jun-04 0:21
Hesham Amin9-Jun-04 0:21 
QuestionHow i Can format Date in Sql Server 7.0 Pin
syed saba8-Jun-04 21:47
syed saba8-Jun-04 21:47 
AnswerRe: How i Can format Date in Sql Server 7.0 Pin
Hesham Amin9-Jun-04 6:50
Hesham Amin9-Jun-04 6:50 
GeneralRe: How i Can format Date in Sql Server 7.0 Pin
-Dr_X-9-Jun-04 15:30
-Dr_X-9-Jun-04 15:30 
Generalgetting value from newly inserted row Pin
sharonz8-Jun-04 20:54
sharonz8-Jun-04 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.