Advertisement

06.16.2008 at 12:00PM PDT, ID: 23489270
[x]
Attachment Details

Insert statement

Asked by sevensnake77 in .Net Editors & IDEs, Microsoft Applications, Microsoft Development

Tags:

yes I have and application where and excel sheet is programatically transformed to
it will insert into an MS-Sql database.

It seems like my insertion is not working.

there are no errors but my database shows blank spaces, so the data is not getting
transferred.

not sure what else to do.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
myReader.Close() 'Close connection string
        '*****************************Add Rows to DataTable**********************************
 
        Dim rowCt As Integer
        Dim row1 As DataRow
        'Dim ConnRecommendNew As New SqlConnection(Application("A1SConnString"))
        'ConnRecommendNew.Open()
        row1 = exDataTable.NewRow
 
        For rowCt = 0 To i
 
            row1 = exDataTable.NewRow()
            row1("UPC") = exData(rowCt, 0)
            row1("Order") = exData(rowCt, 1)
            row1("Description") = exData(rowCt, 2)
            row1("PK") = exData(rowCt, 3)
            row1("SIZE") = exData(rowCt, 4)
            row1("SALE QTY") = exData(rowCt, 5)
            row1("SALE COST") = exData(rowCt, 6)
            row1("CASE COST") = exData(rowCt, 7)
            row1("DEAL") = exData(rowCt, 8)
            row1("DEAL COST") = exData(rowCt, 9)
            row1("UNIT QTY") = exData(rowCt, 10)
            row1("UNIT COST") = exData(rowCt, 11)
            row1("RETAIL") = exData(rowCt, 12)
            row1("PAL") = exData(rowCt, 13)
            row1("TIER") = exData(rowCt, 14)
            row1("TRIP PTS.") = exData(rowCt, 15)
 
            ' Be sure to add the new row to the DataRowCollection. 
            exDataTable.Rows.Add(row1)
 
        Next rowCt
 
 
        ''##################################################################
 
        '' ****** Here saving to the Recommend table from datagrid
 
        Dim ConnRecommendNew As New SqlConnection(Application("A1SConnString"))
        ConnRecommendNew.Open()
        ' For Each row1 In DS.Tables(0).Rows
        Dim UPC As String = row1("UPC").ToString()
        Dim Description As String = row1("Description").ToString()
        Dim ImportRecommend As New SqlCommand
        ImportRecommend = ConnRecommendNew.CreateCommand
 
 
        ImportRecommend.CommandType = CommandType.Text
        ImportRecommend.CommandText = "Insert into SalesItems(Upc,Description) Values (@Upc,@Description)"
        ImportRecommend.Parameters.Add("@Upc", SqlDbType.VarChar, 50).Value = UPC
        ImportRecommend.Parameters.Add("@Description", SqlDbType.VarChar, 50).Value = Description
        ImportRecommend.ExecuteNonQuery()
        MyCommand = New System.Data.OleDb.OleDbDataAdapter(sqlStr, MyConnection)
        MyCommand.TableMappings.Add("Table", "SalesBatch")
        DataGrid1.DataSource = exDataTable
        DataGrid1.DataBind()
        ImportRecommend.Dispose()
 
        ' ConnRecommendNew.Close()
        ConnRecommendNew.Close()
        MyConnection.Close()
        '  Next
    End Sub
[+][-]06.16.2008 at 02:10PM PDT, ID: 21797534

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2008 at 02:19PM PDT, ID: 21797619

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.16.2008 at 02:21PM PDT, ID: 21797636

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 05:27AM PDT, ID: 21802191

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .Net Editors & IDEs, Microsoft Applications, Microsoft Development
Tags: Insert statement
Sign Up Now!
Solution Provided By: apeter
Participating Experts: 1
Solution Grade: B
 
 
[+][-]06.17.2008 at 06:28AM PDT, ID: 21802708

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 06:53AM PDT, ID: 21802977

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 07:34AM PDT, ID: 21803419

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906