15,893,266 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by kyrons (Top 14 by date)
kyrons
14-Feb-21 3:49am
View
Here is my contructed code but not working.
Dim connstring As String
connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=studentrecords.accdb"
Dim conn As OleDbConnection = New OleDbConnection(connstring)
Dim displaystr As String = "SELECT studentfullname, dateofbirth, Round(DateDiff('m',studenprofile_records.Date_of_Birth,Date())/12,2) AS Age FROM studentprofile_records WHERE Age BETWEEN'" & CInt(txtagefrom.Text) & "' AND Age <='" & CInt(txtageto.Text) & "'"
Dim cmddisplay As New OleDbCommand(displaystr, conn)
conn.Open()
cmddisplay.ExecuteNonQuery()
conn.Close()
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.ZoomMode.PageWidth)
Me.ReportViewer1.RefreshReport()
kyrons
24-Jun-20 5:51am
View
This is the corrected codes:
Code:
Dim con1 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= database1.accdb")
Dim con2 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= database2.accdb")
con2.Open()
Dim CompQuery As String = "SELECT COUNT(*) FROM sampletable WHERE FirstName = @FirstName AND LastName = @LastName"
Dim compCommand As OleDbCommand = New OleDbCommand(CompQuery, con2)
compCommand.Parameters.AddWithValue("@FirstName", "FirstName")
compCommand.Parameters.AddWithValue("@LastName", "LastName")
If Convert.ToInt32(compCommand.ExecuteScalar()) > 0 Then
'ignoring duplicate entries msgbox("Some records fail to save because it would create duplicate
entries!")
Exit Sub
Else
'Create the data adapter with a SelectCommand using the first connection.
Dim da As New OleDb.OleDbDataAdapter("SELECT FirstName, LastName FROM table1 ", con1)
'Add the InsertCommand with the second connection.
da.InsertCommand = New OleDb.OleDbCommand("INSERT INTO sampletable (FirstName, LastName) VALUES (@FirstName, @LastName)", con2)
'Add the insert parameters.
da.InsertCommand.Parameters.Add("@FirstName", OleDb.OleDbType.VarChar, 50, "FirstName")
da.InsertCommand.Parameters.Add("@LastName", OleDb.OleDbType.VarChar, 50, "LastName")
'Keep the records in a state where they can be inserted into the destination table.
da.AcceptChangesDuringFill = False
Dim dt As New DataTable
'Get the data from the source database.
da.Fill(dt)
'Save the data to the destination database.
da.Update(dt)
MsgBox("Data Added!")
con1.Dispose()
con2.Dispose()
End If
kyrons
24-Jun-20 5:15am
View
Sorry that in this portion of code was mistaken. It was just typographical error. Sorry that it making you confused.
"But when you insert with the command
da.InsertCommand = New OleDb.OleDbCommand("INSERT INTO sampletable (Fullname, FirstName) VALUES (@FirstName, @LastName)", con2)"
Instead:
da.InsertCommand = New OleDb.OleDbCommand("INSERT INTO sampletable (FirstName, LastName) VALUES (@FirstName, @LastName)", con2)
kyrons
3-Jun-20 4:47am
View
Wow...Thank you so much Richard Deeming, my friend, it works perfectly.
kyrons
11-May-20 6:30am
View
Why if I delete "name" it proceeds adding some columns but if it still there the columns are not adding? I think the "name" is the one that is recognized that if it is existing you cannot add columns.
kyrons
11-May-20 6:17am
View
Same error prompted. Field 'name' already exists in table 'Table1'. Any modification please.
kyrons
11-May-20 6:01am
View
Thanks for your help my friend but it's not working. If I erase some columns and adding it again it did not work. I think your code is somehow like performing "On error Resume Next" that it did not display or prompt an error message. Any suggestion please.
kyrons
15-May-19 4:19am
View
Thanks..I did not notice the *(means all). Now I revised the sql statement to: sql = "SELECT column1, column4, column6 FROM publicationinfo" and it works.
kyrons
15-May-19 0:58am
View
Thanks...solved.
kyrons
21-Mar-19 4:45am
View
Thanks for your effort Maciej Los. Where exactly to put the code? Is it in Dataset TableAdapter query or just inside the button code: Private Sub Buttonseparate_Click(sender As System.Object, e As System.EventArgs) Handles Buttonseparate.Click
kyrons
21-Mar-19 4:26am
View
Thanks _dude for clarification. What I really want is that using vb.net project with one (1) button in visual basic form I want to separate alphabet and number from each other.
kyrons
12-Dec-18 20:40pm
View
Thank you Sir Richard MacCutchan. I can fill data in listbox but I cannot clear the existing data. I used listbox1.datasource = nothing and listbox1.items.clear but I got an error "Items collection cannot be modified when the DataSource property is set." can you give me the solution or any suggestion to clear the existing items in listbox?
kyrons
26-Jul-16 6:16am
View
Any idea on how to handle this? I think I can do copying records if they are in the same connection and if in the same path. The problem only is that the two databases were not in the same path. Please help me.
kyrons
26-Jul-16 6:11am
View
I have used the textbox3 again because this is the database source where the copied records came from. "SELECT * FROM pop IN '" & TextBox3.Text &"
I have used also the "INSERT INTO pop" because this is the destination database table for inserting the new records.
Show More