Jump to content
Xtreme .Net Talk

tuningd

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by tuningd

  1. Ok I tried searching but I can't get to the other pages. I need to delete a table from a access database and I have no idea the sql to send? Also how do a copy a table's structure so the new table will be the same as the one I am copying. I do not care about the data just the columns and how they are set up. Thank you Dale
  2. IT WORKED YAH Thank you techmanbd!
  3. Yes I just tried that and got the same error. With ro.Item(0)=CType(reader.GetString(0), String) I think is should also, but when I created the table in the program it wants just integers. So do know how I can change the table to accept strings? And also wouldn�t the data = reader.GetSchemaTable line change the table to be just like the database table?
  4. I don't know it is possible but could you copy the file and open the copied version that is not being written to?
  5. Ok I am writing a inventory program. I am using ms access and I keep getting an error that I think it is telling me that the second column I am trying to read for the table it thinks it should be integer and I need it to be a string. Here is the problem code. Dim loc As String loc = System.Environment.CurrentDirectory loc = Microsoft.VisualBasic.Left(loc, loc.Length - 3) Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + loc + "Inventory.mdb" Dim Conn As New OleDb.OleDbConnection(sConnString) Dim tab As String tab = Me.Text tab = Microsoft.VisualBasic.Right(tab, tab.Length - 20) tab = tab.Replace(" ", "_") Try Dim sCommand As String = "Select * From " + tab Conn.Open() Dim Command As New OleDb.OleDbCommand(sCommand, Conn) Dim reader As OleDb.OleDbDataReader reader = Command.ExecuteReader data = reader.GetSchemaTable Dim ro As DataRow Do While reader.Read() ro = data.NewRow ro.Item(0) = CType(reader.GetValue(0), Integer) ro.Item(1) = CType(reader.GetString(1), String) ro.Item(2) = CType(reader.GetString(2), String) ro.Item(3) = CType(reader.GetString(3), String) ro.Item(4) = CType(reader.GetString(4), String) data.Rows.Add(ro) Loop reader.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally Conn.Close() End Try This is what the table in the database looks like Item Number | Part Number | Box Number | Description |Exeptions 1 H3300TB Box P3 Monitor Nothing ok and here is all most the same code and it works just fine Dim loc As String loc = System.Environment.CurrentDirectory loc = Microsoft.VisualBasic.Left(loc, loc.Length - 3) Dim sConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + loc + "Inventory.mdb" Dim Conn As New OleDb.OleDbConnection(sConnString) Try Dim sCommand As String = "Select [systemName] From System" Conn.Open() Dim Command As New OleDb.OleDbCommand(sCommand, Conn) Dim reader As OleDb.OleDbDataReader reader = Command.ExecuteReader Do While reader.Read() lbsystem.Items.Add(reader.GetString(0)) Loop reader.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally Conn.Close() End Try The Image attached is of the erroe
×
×
  • Create New...