Hey Guys I am trying to Bulk Insert a Text file into an SQL DB through VB6. I have never used this Object Model before so any help would be appreciated. I have this code from MSDN but cant seem to implement it?? ----------------------------- 'initialize Payroll table in DTS_UE db with bulk data Dim objPackage As DTS.Package2 Dim objConnect As DTS.Connection2 Dim objStep As DTS.Step Dim objTask As DTS.Task Dim objBulkCopy As DTS.BulkInsertTask On Error GoTo Handler Set objPackage = New DTS.Package 'create database connection Set objConnect = objPackage.Connections.New("SQLOLEDB.1") With objConnect .ID = 1 .DataSource = "(Local)" .UseTrustedConnection = True End With objPackage.Connections.Add objConnect 'create step and task, specify data file and format Set objStep = objPackage.Steps.New Set objTask = objPackage.Tasks.New("DTSBulkInsertTask") Set objBulkCopy = objTask.CustomTask With objBulkCopy .Name = "BulkInsTask" .DataFile = "C:\Development\Bulk Insert\TEST.txt" .ConnectionID = 1 .DestinationTableName = "BULK_INSERT_TEST..BI_Test" .FieldTerminator = "-t" .RowTerminator = "\n" End With 'link step to task to package, run package objStep.TaskName = objBulkCopy.Name objStep.Name = "BulkInsStep" With objPackage .Steps.Add objStep .Tasks.Add objTask .FailOnError = True .Execute End With
superwinsock
Posts
-
Bulk Insert Help -
Hardware configurationDo you mean through VB or just visualy through windows? Second option: Click Control Panel, System, Hardware Tab, then Device Manager Later
-
Custom ColumheaderHey Ole Well your post of the tables is somewhat confusing Teachers |Prof. Clark | Prof. Brooke | Prof. Daniels ___________________________________________ Time ____________________________________________ 8:00 | Peter Robertson | Blank|Blank ____________________________________________ 9:00 |James Keith | Blank|Blank etc... 1.Are your headers always going to be the same? If so then you can just hard code them. 2. Just tell me what the headers are and from there I can get the info from the tables. 3. In a listbox you have to use COURIER NEW as your font, else the spacing is never going to be right. 4. You have to pre-determine your column lengths before you populate the listbox. IE: If you have a column named First_Name, thats 10 characters, and the name is Ole. You will have to add 7 spaces after the name to make the next column's data in line with its header. Probably a bit confusing the way I explained but just tell me the column headers and I will write the sproc. Thats the easy part. You will have to do the front end. Later Cliff
-
Custom ColumheaderWell thats no problem?? Just use a JOIN statement to join the teacher and Student tables... This can be done in a sproc. If you really get stuck, just post the Student and Teacher Tables structures and what you want to get out of them in your record set, and I will gladly help you write the sproc. Later Cliff
-
Custom ColumheaderHey Ole123 Well I will leave the front end to you, but if you choose to go with a stored proc then here is the basic layout including getting the headers... CREATE PROCEDURE MP_CB_Get_CallBacks AS -- V1.0.0 : Super Winsock : 4 March 2002 -- Returns the Column names and width for the grid. -- It also returns the data. SET NOCOUNT ON --Returns the Column names and it's width. -- 1st is the column name & 2nd is the column width and so on. SELECT 'Id', 0, 'Student_Name', 0, 'Teacher_Name', 2000, 'Subject', 1500, 'Time', 1500, 'Date', 1500 SELECT [Id], Student_Name, Teacher_Name, Subject, Time, Date FROM ?Table SET NOCOUNT OFF GO /* Hope this helps?
-
Custom ColumheaderAre you using a stored procedure? Give more info about your requirements... Later
-
Need help with DateThis is for VB6... not sure about .net Say your first date is 20/12/2000 and your second date is 15/12/2004 Dim strDate1 As String Dim strDate2 As String Dim strDifference As String strDate1 = "20/12/2000" strDate2 = "15/12/2004" strDifference = DateDiff("yyyy", strDate1 , strDate2) msgbox strDifference 'This will be 4 years Dont know if that is what you were looking for?? Anyway... Later
-
Capturing Screenshots into an AVI fileThanks Dave for the quick responses. I understand the problem I will face with resources but this would only be installed on new agents p.c's. This would help us to see how he/she is performing... I would only have to capture the video side of things because I already have a datavoice which captures all incoming and outgoing calls. Just incase of any problems. Anyway thanks for you help Later
-
Capturing Screenshots into an AVI fileI need to code this because our software is connected to the PBX, so when a call comes in I would like to capture what the agent does on his/her screen. This will enhance our ability to maintain standards. Any ideas??
-
Capturing Screenshots into an AVI fileHey All Does anyone know how to capture or record the screen into an AVI file through VB? I work in a call centre and for training purpose would like to capture the agents movements while on a call... Any help would be great! Later
-
html text wrappingHey There is an html tag: Not sure if this is what u lookin for?? Anyway Later
-
How the disable the resize function of a formIf you haven't resolved this yet..... 'In the Resize event of your form set the size properties to be constant Private Sub MDIForm_Resize() On Error GoTo Handler With Me .Height = g_lngHeight + 1425 .Width = g_lngWidth + 180 .Top = 0 End With Exit Sub Cliff
-
ExcelHey Anand Chakravarthy You might want to give a little more specific detail on what you are trying to achieve... Cliff
-
selecting a data in flexgridHey Gary Ok... Once you have populated your flexgrid: You will select a row of data by clicking on the flexgrid row. Then(just as example) you have a command button called cmdENTER. When you have selected a row and then click cmdENTER, you put the selected rows information in an array called strCustData. It has been dimentioned to (0 to 12) because there are 13 columns in my row. 'So this code will go in the same form as your selected flexgrid 'Copy this code into VB, it will be easier to read Private sub cmdENTER_Click() Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients 'This just checks if a valid record was selected If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else 'Sets my variable to the first column's value of the selected row lngClientId = .TextMatrix(.Row, 0) 'here we assign the rows values to our array For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With 'Now we call our next form where you want the selected row's data ' to be displayed 'Load the form Call Load(frmUpdate) With frmUpdate 'Then in frmUpdate create a Public Sub call MP_ClientDetails 'and here we call that Sub and pass through our array 'strCustData) .MP_ClientDetails lngClientId, strCustData .Show vbModal End With End Sub 'Here is the code for that Public Sub which should be in frmUpdate Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte 'Here we assign the values from our Array into the textboxes on 'frmUpdate (Obviously this could be changes to a grid or ??) For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount End Sub I really suck at explaining things but hope this helps a little. If confusion reigns just tell me and I will try explain in a different way Regards Cliff
-
selecting a data in flexgridHi Gary Could you elaborate on what it is exactly you are trying to do? Is your question... When I select a row of info on a grid, how do I populate another page with the selected data?? Cliff
-
selecting a data in flexgrid'This is on the main form Dim strCustData(0 To 12) As String Dim lngClientId As Long Dim bytCount As Byte With grdClients If .TextMatrix(.Row, 0) = "" Or .TextMatrix(.Row, 1) = "N/A" Then MsgBox "Please Select a Record" Exit Sub Else lngClientId = .TextMatrix(.Row, 0) For bytCount = 0 To UBound(strCustData, 1) strCustData(bytCount) = .TextMatrix(.Row, bytCount + 1) Next bytCount End If End With Call Load(frmUpdate) With frmUpdate .MP_ClientDetails lngClientId, strCustData .Show vbModal End With ---------------------------------------------- 'This is a function in the receiving page Public Sub MP_ClientDetails(lngClientId As Long, strCustData() As String) Dim bytCount As Byte For bytCount = 0 To UBound(strCustData, 1) txtCustDetails(bytCount).Text = strCustData(bytCount) Next bytCount exit sub Hope this helps!