Click here to Skip to main content
15,916,527 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralHelp with a script Pin
Anonymous16-Dec-04 22:37
Anonymous16-Dec-04 22:37 
GeneralRe: Help with a script [EDITED] Pin
Dave Kreskowiak17-Dec-04 5:56
mveDave Kreskowiak17-Dec-04 5:56 
GeneralRe: Help with a script [EDITED] Pin
Anonymous23-Dec-04 16:07
Anonymous23-Dec-04 16:07 
GeneralRe: Help with a script [EDITED] Pin
Dave Kreskowiak23-Dec-04 16:17
mveDave Kreskowiak23-Dec-04 16:17 
GeneralColumns in a string in VB.NET Pin
Chaos Machine16-Dec-04 18:11
Chaos Machine16-Dec-04 18:11 
GeneralRe: Columns in a string in VB.NET Pin
OICU81216-Dec-04 18:37
OICU81216-Dec-04 18:37 
GeneralDatabase access through VB.Net Pin
nyjcr16-Dec-04 14:39
nyjcr16-Dec-04 14:39 
GeneralRe: Database access through VB.Net Pin
Chaos Machine16-Dec-04 18:06
Chaos Machine16-Dec-04 18:06 
Hello CJ. Ok i am new too in vb.net and i had such a problem to find a solution with Access and VB.NET. BUT i found the answer that you are looking for too. Here it is:

************************* Searching in a database:

Dim strConnection As String = OleDbConnection1.ConnectionString

(the connectionString will be a string created from the VB when you specify where your database is)

Dim connect As New OleDbConnection(strConnection)
Dim test As String
Dim te As String
Dim SQLString As String
connect.Open()
te = txtAreaToSearch.Text
SQLString = "SELECT * from informations WHERE Area =" & "'" & te & "'"
Dim cmd As New OleDbCommand(SQLString, connect)
Dim reader As OleDbDataReader = cmd.ExecuteReader()
While reader.Read()
txtCouncilName.Text = reader.GetValue(1) 'gets the value of the first attribute in your databse eg postCodeOfTheArea

End While
reader.Close()
connect.Close()

In this example you will need a OleDbConnection1 and a OdbcCommand1 objects. Also the following must be put at the start :
Imports System
Imports System.Data
Imports System.Data.OleDb

What the example does is to search in a database on the TABLE informations for an AREA with the name that is in a TEXTBOX called txtAreaToSearch.

********************************** Deleting an entry
Dim SQLStringUpdateKeys As String
Dim SQLStringUpdateArea As String
Dim icount As Integer
Dim icount1 As Integer
Dim strConnection As String = OleDbConnection1.ConnectionString
Dim connect As New OleDbConnection(strConnection)

Dim inputOption As Integer

inputOption = MsgBox("Are you sure you want to delete this record", MsgBoxStyle.OKCancel, "Are you sure?")
If inputOption = 1 Then
connect.Open()
On Error Resume Next
SQLStringUpdateArea = "DELETE FROM informations WHERE Area = '" & txtAreaName.Text & "'"
Dim cmd1 As New OleDbCommand(SQLStringUpdateArea, connect)
icount1 = cmd1.ExecuteNonQuery
connect.Close()

MessageBox.Show("Records Deleted in table: " & icount1)

Else
Exit Sub
End If

************************* inserting a new entry

Dim SQLStringUpdateKeys As String
Dim SQLStringUpdateArea As String
Dim icount As Integer
Dim icount1 As Integer



Dim strConnection As String = OleDbConnection1.ConnectionString
Dim connect As New OleDbConnection(strConnection)
connect.Open()
On Error Resume Next
SQLStringUpdateKeys = "insert into informations values('" & txtKeyWordUp.Text & "','" & txtAreaNameUp.Text & "')"

Dim cmd As New OleDbCommand(SQLStringUpdateKeys, connect)
cmd.ExecuteNonQuery()
icount = cmd.ExecuteNonQuery
connect.Close()
connect.Dispose()
MessageBox.Show("New records added in table: " & icount)


Hope this helps. Smile | :)



Still trying to find the way
GeneralRe: Database access through VB.Net Pin
nyjcr17-Dec-04 6:34
nyjcr17-Dec-04 6:34 
GeneralRe: Database access through VB.Net Pin
OICU81216-Dec-04 18:23
OICU81216-Dec-04 18:23 
GeneralRe: Database access through VB.Net Pin
nyjcr17-Dec-04 6:37
nyjcr17-Dec-04 6:37 
GeneralRe: Database access through VB.Net Pin
Anonymous17-Dec-04 8:03
Anonymous17-Dec-04 8:03 
GeneralRe: Database access through VB.Net Pin
OICU81217-Dec-04 19:08
OICU81217-Dec-04 19:08 
GeneralTextBox Alpha blending Pin
Iasonic16-Dec-04 12:53
Iasonic16-Dec-04 12:53 
QuestionMultiple Resource Files? Pin
TAlvord16-Dec-04 12:46
TAlvord16-Dec-04 12:46 
General.DTD write error after modifying XML with XmlDocument Pin
GreenEyes16-Dec-04 10:53
GreenEyes16-Dec-04 10:53 
Generalurgent custom control with collection of controls Pin
ddsmith16-Dec-04 9:33
ddsmith16-Dec-04 9:33 
GeneralRe: DB Connection Question Pin
Dave Kreskowiak16-Dec-04 7:07
mveDave Kreskowiak16-Dec-04 7:07 
GeneralRe: DB Connection Question Pin
marrik16-Dec-04 8:17
marrik16-Dec-04 8:17 
GeneralHide Checkbox in Checkbox VB Pin
shinay16-Dec-04 5:55
shinay16-Dec-04 5:55 
GeneralRe: Hide Checkbox in Checkbox VB Pin
shinay16-Dec-04 5:56
shinay16-Dec-04 5:56 
GeneralRe: Hide Checkbox in Checkbox VB Pin
Wjousts16-Dec-04 6:15
Wjousts16-Dec-04 6:15 
GeneralRe: Hide Checkbox in Checkbox VB Pin
shinay16-Dec-04 6:18
shinay16-Dec-04 6:18 
GeneralRe: Hide Checkbox in Checkbox VB Pin
shinay16-Dec-04 6:29
shinay16-Dec-04 6:29 
GeneralRe: Hide Checkbox in Checkbox VB Pin
Wjousts16-Dec-04 6:29
Wjousts16-Dec-04 6:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.