Thanks for getting back to me. I'm get started learning more about dataadapters. As for your first statement, could you recommend another way of doing this? Thanks again
culbysl
Posts
-
Insert Records into Access DB -
Insert Records into Access DBI am working on a project that pulls SQL Server data and places it into a MS Access database. The dataset contains 3438 rows, and 0 rows are inserted into Access. There are no errors when the code run, just nothing happens. The code is listed below: Public Function InsertAccessData(ByVal dsTDO_Header as dataset) As String Dim cn As New OleDbConnection(strACCDBConn) Dim strSQL As String = "" Dim DA As New OleDbDataAdapter strSQL = "Select * from TDO_HEADER" DA.SelectCommand = New OleDbCommand(strSQL, cn) DA.FillSchema(dsTDO_Header, SchemaType.Source, "TDO_Header") Dim oleCB As New OleDbCommandBuilder(DA) Try cn.Open() oleCB.GetInsertCommand() DA.Update(dsTDO_Header, "TDO_Header") ''dsTDO_Header contains 3438 records, ''DA.Update inserts 0 Records in db with no errors ''that is the problem cn.Close() cn.Dispose() DA.Dispose() Catch ex As Exception Dim strErrMess As String strErrMess = "Something didn't work right we received this update error: " & ex.Message cn.Close() cn.Dispose() DA.Dispose() Return strErrMess Exit Function End Try Return "Success" End Function Can anyone see where I went astray? Thanks in advance for any help. culbysl
-
VB.NET Access DB DataSet problemThanks once again for your thoughts. I ran console.writeline on both the connection string and the sql statement then using start run opened the database and ran the query that was placed in the output window. What I have found is when I take out the like and run an equal to where I get results in the datagridview on my form. It is becoming obvious that my problem has to do with like in the query which allows it to run in Access but not through the application. My next move is to try % as the wildcard not *. I sure wish I could use SQL Server but that is just not in the cards. Again thanks for all your help.
-
VB.NET Access DB DataSet problemThanks so much for the advise, however using your code for the function I am still returning 0 rows. When I put the query directly into Access I return 8 rows. Again thanks so much for your thought and advise, I'll keep plugging along.
-
VB.NET Access DB DataSet problemI have dropped all my emails into an access database, and now building a vb.NET windows app to query to return needed email bodies. The application runs through the database dataset function and returns 0 rows. I console.writeline the connection string and SQL statement and am able to pull records from the database. I can't see what I have wrong in the code. The function hitting the database is listed below. Please any help would be a really great thing. Thanks in advance. Public Function GetSelectAnd2Records(ByVal strTableName, ByVal strCriteria1, ByVal strCriteria3) As DataSet Dim ds As New DataSet Dim strSQL As String Dim dbConn As New OleDbConnection dbConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\NovaEmailKB\KNOWLEDGE BASE SSC.mdb;" strCriteria1 = "*" & strCriteria1 & "*" strCriteria3 = "*" & strCriteria3 & "*" strSQL = "SELECT [ID], [Subject], [Body], [Received], [From] " & _ "FROM " & strTableName & " " & _ "WHERE (((Body) Like """ & strCriteria1 & """ And (Terminals.Body) Like """ & strCriteria3 & """)) " & _ "ORDER BY Received DESC; " Dim cn As New OleDbConnection(dbConn.ConnectionString) Dim cmd As New OleDbCommand(strSQL, cn) Dim da As New OleDbDataAdapter(cmd) Console.WriteLine(dbConn.ConnectionString) Console.WriteLine(strSQL) Try cn.Open() Console.WriteLine(cn.State) cmd.Connection = cn cmd.CommandText = strSQL cmd.ExecuteNonQuery() da.Fill(ds, "SelectAnd2Rtn") If cn.State = ConnectionState.Open Then cn.Close() End If cn.Dispose() cn = Nothing da.Dispose() da = Nothing Catch ex As Exception MsgBox("An unexpected MS Access error has occured: " & ex.Message) If cn.State = ConnectionState.Open Then cn.Close() End If cn.Dispose() cn = Nothing da.Dispose() da = Nothing Return Nothing Exit Function End Try Return ds End Function
-
Build ErrorThanks Angus for your thoughts, however your suggestion did not unfortunately work. In the same sub I have created a new word.application with the following syntax: Dim WordApp As Word.Application WordApp = New Word.Application() WordApp.Visible = True WordApp.Documents.Open(strPath) WordApp = Nothing The syntax above works perfectly, opening the word doc. Again thanks for your thoughts and ideas. SL Culbertson
-
Build ErrorI'm having a strange problem declaring a NEW Excel.Application. I get a blue line under the line xlApp = New Excel.Application(). When I hover over the line the error states "'New' cannot be used on an interface.". I'm a little confused with the interface reference. I have referenced Excel, and MicrosoftOffice.Core and imported them on the page. The problem code is below. Imports Microsoft.Office Imports Excel Imports Microsoft.VisualBasic Imports Microsoft.Win32 Dim xlApp As Excel.Application Dim xlWB1 As Excel.Workbook xlApp = New Excel.Application() <----- Line with Error "'New' cannot be used on an interface." xlApp.Visible = True xlWB1 = xlApp.Workbooks.Open(strPath) xlWB1 = Nothing I am using the same code to open Word docs and PowerPoint presentations. Any suggestions would be very welcome. Thanks in advance
-
VB.NET Windows Form Reading Excel dumping data into SQL serverI situation is I need to pull the data from an Excel Spreadsheet and Insert it into a SQL Server DB. connecting excel via OleDb connection: strExCN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileName & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""" which is connecting as it should. I hope someone can lend a hand on this. I can open the excel file and begins to read but when I come across an empty file I get a dbNull error. I have changed my select statement from "select * from [worksheet$]" to "select isnull(ColumnName, '') from [worksheet$]" and now am receiving and error saying OleDbException was unhandled Wrong number of arguments used with function in query expression 'IsNull('Column Name', '')'. Any help on this error would be wonderful. Thanks in advance culby sl
-
debugging SQL Server Stored Procedures in .NET ideI have in the distant past been able to debug SQL Stored procedures in the .NET ide, and now I have not been able to figure out the correct configuration. If anyone has this knowledge please give me and a multitude of others an hand with this very helpful tool. Thanks in advance for your help. SL
-
vb.net extracting the first letter of a stringThanks Marc and David for your help. I'm off and running on this end now. culbysl
-
vb.net extracting the first letter of a stringI'm pretty new at programming, and could sure use some help. I am trying to pull the first letter from a textbox string. I have looked through all of my reference material and old code but can't seem to find it. Please help, thanks. culbysl