locked
oledb add row and now.month question RRS feed

  • Question

  • Hiya folks

    Ive got my code, it add the data but not how i want it,  when i add row i wnat it to go to row 1,2,3 and so on but its adding the data to say cell 5000, 5001 and so on.  any way to get it go in at number 1 and 2 and what not.

    Now.month shows as a number how can i get it to reference it as a name so 10=Oct.  and can i use it without referencing it into a textbox.

    ie

    textbox1.text = now.month

    if textbox.text = 10 then

    textbox.text = "Oct"

    heres my OLEDB code as it stands: 

    UserExcel is my .xls file im working with, textbox 37 has the month in. everything is textboxes as the refenced names.

     

       ' Puts data into Excel
    
        Dim Cmd As System.Data.OleDb.OleDbCommand
    
        Dim SQL As String
    
        Dim objCmd As New System.Data.OleDb.OleDbCommand
    
        Dim dataadapter = New System.Data.OleDb.OleDbDataAdapter
    
        Dim con As New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" & UserExcel2 & ";Extended Properties=Excel 8.0;")
    
        SQL = "INSERT INTO [" & TextBox34.Text & "$] (JobNumber, LogDate, DateDealt, DealtWithBy, Notes) VALUES ( @JobNumber,@LogDate,@DateDealt,@DealtWithBy,@Notes)"
    
        Cmd = New System.Data.OleDb.OleDbCommand(SQL, con)
    
        objCmd = New System.Data.OleDb.OleDbCommand(SQL, con)
    
        objCmd.Parameters.Add("@JobNumber", Data.OleDb.OleDbType.Char).Value = JobNumberTextBox.Text.ToString
    
        objCmd.Parameters.Add("@LogDate", Data.OleDb.OleDbType.Char).Value = DateOutTextBox.Text.ToString
    
        objCmd.Parameters.Add("@Operator", Data.OleDb.OleDbType.Char).Value = QueryOperatorTextBox.Text.ToString
    
        objCmd.Parameters.Add("@Department", Data.OleDb.OleDbType.Char).Value = DeptToTextBox.Text.ToString
    
        objCmd.Parameters.Add("@Reason", Data.OleDb.OleDbType.Char).Value = BriefReasonTextBox.Text.ToString
    
        objCmd.Parameters.Add("@Other", Data.OleDb.OleDbType.Char).Value = OtherNotesTextBox.Text.ToString
    
        objCmd.Parameters.Add("@ShapeFile", Data.OleDb.OleDbType.Char).Value = ShapeFileTextBox.Text.ToString
    
        con.Open()
    
        objCmd.ExecuteNonQuery()
    
        con.Close()
    

    Thanks for the help. What not to put on an Employee evaluation: This employee has hit rock bottom and shows signs of starting to dig.
    Tuesday, October 19, 2010 10:02 AM

Answers