|
-
Mar 24th, 2016, 02:14 PM
#1
Thread Starter
New Member
SQl insert into help
I'm all new to coding still and only really know what i've been taught in college for our projects. For this one we needed to connect to a database and be able to select, update, delete, and insert into a table for whatever we're doing. With the code I have now I can select from the table and it works but I cannot insert into it, I think I might have messed up the code for it or at least I hope I did because other then that I'd have no idea what would be wrong. I have the access file saved in the debug file where it normally works for update and selecting. Heres my code so far, again it's pretty basic. I am saving this as 2010 visual studio's but using 2015 to edit it just because apparently it needs to be 2010 for it to be marked but the file will load in 2015 and will be saved in 2010 normally. Idk if that might have anything to do with it but you might?
Public Class Newuservb
Dim Connection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database1.accdb")
Dim dt As New DataTable
Dim DataAdapter As New OleDb.OleDbDataAdapter
Dim TableSearchUser As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Logins.Close()
End Sub
Private Sub Newuservb_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Dim username As String
Dim password As String
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
username = TextBox1.Text
password = TextBox2.Text
Connection.Open()
DataAdapter = New OleDb.OleDbDataAdapter("INSERT INTO Table1 ([UserName], [Password]) VALUES ('" & username & "' , '" & password & "') ", Connection)
Connection.Close()
End Sub
End Class
I've tried changing the column names from username and password but it doesn't make a difference. No error comes up and it doesn't crash at all it just won't show up in the database.
Tags for this Thread
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
|