|
-
Aug 16th, 2006, 09:18 PM
#1
Thread Starter
Lively Member
[RESOLVED] insert memo field msaccess vb.net
We are trying to read from an MS access database table and write into multiple tables. Both source and destination have memo fields that store tag related data with special characters. We are trying to write a vb.net program using datareader and have not been able to insert the read data into the destination column successfully.
Is there any way to get around this issue. We are at our wits end at this point.
Thanks!!
-
Aug 16th, 2006, 09:29 PM
#2
Re: insert memo field msaccess vb.net
To give us an idea of what the issue might be, how about you show us what you're doing at the moment? There's not much point suggesting something that you may already be doing.
-
Aug 16th, 2006, 09:37 PM
#3
Thread Starter
Lively Member
Re: insert memo field msaccess vb.net
Iam trying to copy the contents of fields from one table in a access database to other fields in another table of a second access database.
Iam pasting the code that iam working on.iam not able to copy the contents of the memo fields into the destination database.in this col6 and col7 are the memo fields .
Dim cn As OleDbConnection
Dim cn_dest As OleDbConnection
Dim cmd As OleDbCommand
Dim cmdold As OleDbCommand
Dim dr As OleDbDataReader
Dim icount As Integer
Dim str As String
Dim col3 As Integer
Dim col4 As String
Dim col5 As String
Dim col6 As String
Dim col7 As String
Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Amoushmi\CMS\Old_db\cMS.mdb;")
'provider to be used when working with access database
cn.Open()
cmdold = New OleDbCommand("select * from WebContent", cn)
dr = cmdold.ExecuteReader
cn_dest = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Amoushmi\CMS\New_cms\DB\aCMS.mdb;")
cn_dest.Open()
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("DELETE * FROM [tblContent_languages]", cn_dest)
AccessCommand.ExecuteNonQuery()
While dr.Read()
col3 = CInt(dr(1))
col4 = CStr(dr(2))
col5 = CStr(dr(4))
col6 = CStr(dr(5))
' col7 = CStr(dr(21))
str = "insert into tblContent_languages(templateid,contentName,contentTitle,contentBody) values (" & col3 & ",'" & col4 & "','" & col5 & "','" & col6 & "')"
'string stores the command and CInt is used to convert number to string
cmd = New OleDbCommand(str, cn_dest)
icount = cmd.ExecuteNonQuery
End While
Catch
End Try
dr.Close()
cn.Close()
cn_dest.Close()
-
Aug 16th, 2006, 09:50 PM
#4
Re: insert memo field msaccess vb.net
You should not be using string concatenation to build SQL statements at the best of times, but if you have large memo fields then you're going to break the SQL statement character limit pretty quickly.
VB Code:
str = "INSERT INTO tblContent_languages (templateid, contentName, contentTitle, contentBody) VALUES (@TemplateID, @ContentName, @ContentTitle, @ContentBody)"
cmd = New OleDbCommand(str, cn_dest)
cmd.Parameters.AddWithValue("@TemplateID", col3)
cmd.Parameters.AddWithValue("@ContentName", col4)
cmd.Parameters.AddWithValue("@ContentTitle", col5)
cmd.Parameters.AddWithValue("@ContentBody", col6)
-
Aug 16th, 2006, 10:09 PM
#5
Thread Starter
Lively Member
Re: insert memo field msaccess vb.net
That worked! Thanks a bunch!
-
Aug 16th, 2006, 10:21 PM
#6
Re: insert memo field msaccess vb.net
Cool. Don't forget to resolve your thread from the Thread Tools menu.
-
Aug 16th, 2006, 10:28 PM
#7
Re: insert memo field msaccess vb.net
Fyi, Aprox. 64,000 characters for an Access sql string limit.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|