Click here to Skip to main content
15,921,959 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: DataReader with SQL Join Pin
C#Coudou2-Feb-12 21:57
C#Coudou2-Feb-12 21:57 
GeneralRe: DataReader with SQL Join Pin
Wayne Gaylard2-Feb-12 22:13
professionalWayne Gaylard2-Feb-12 22:13 
AnswerRe: DataReader with SQL Join Pin
Johan Hakkesteegt2-Feb-12 23:35
Johan Hakkesteegt2-Feb-12 23:35 
AnswerRe: DataReader with SQL Join Pin
Dave Kreskowiak3-Feb-12 2:28
mveDave Kreskowiak3-Feb-12 2:28 
Questionvb.net Pin
Member 82843502-Feb-12 18:58
Member 82843502-Feb-12 18:58 
AnswerRe: vb.net Pin
Simon_Whale2-Feb-12 21:50
Simon_Whale2-Feb-12 21:50 
AnswerRe: vb.net Pin
Eddy Vluggen3-Feb-12 0:22
professionalEddy Vluggen3-Feb-12 0:22 
QuestionCopy Content from Word Docuemnt to RichBox Pin
Peace4all2-Feb-12 17:50
Peace4all2-Feb-12 17:50 
AnswerRe: Copy Content from Word Docuemnt to RichBox Pin
Wayne Gaylard2-Feb-12 19:19
professionalWayne Gaylard2-Feb-12 19:19 
Questionshow/hide datagridview rows by setting trackbar value Pin
bezkintos2-Feb-12 14:09
bezkintos2-Feb-12 14:09 
AnswerRe: show/hide datagridview rows by setting trackbar value Pin
Luc Pattyn2-Feb-12 15:07
sitebuilderLuc Pattyn2-Feb-12 15:07 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
bezkintos3-Feb-12 11:51
bezkintos3-Feb-12 11:51 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
Alan N3-Feb-12 13:01
Alan N3-Feb-12 13:01 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
bezkintos3-Feb-12 14:43
bezkintos3-Feb-12 14:43 
AnswerRe: show/hide datagridview rows by setting trackbar value Pin
Luc Pattyn4-Feb-12 3:30
sitebuilderLuc Pattyn4-Feb-12 3:30 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
bezkintos4-Feb-12 6:22
bezkintos4-Feb-12 6:22 
AnswerRe: show/hide datagridview rows by setting trackbar value Pin
Luc Pattyn4-Feb-12 6:43
sitebuilderLuc Pattyn4-Feb-12 6:43 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
bezkintos4-Feb-12 7:51
bezkintos4-Feb-12 7:51 
AnswerRe: show/hide datagridview rows by setting trackbar value Pin
Luc Pattyn4-Feb-12 8:02
sitebuilderLuc Pattyn4-Feb-12 8:02 
GeneralRe: show/hide datagridview rows by setting trackbar value Pin
bezkintos4-Feb-12 8:34
bezkintos4-Feb-12 8:34 
AnswerRe: show/hide datagridview rows by setting trackbar value Pin
Luc Pattyn4-Feb-12 9:19
sitebuilderLuc Pattyn4-Feb-12 9:19 
Questionhaving trouble replacing Trademark and Registered symbol with Regex Pin
David Mujica2-Feb-12 6:18
David Mujica2-Feb-12 6:18 
AnswerRe: having trouble replacing Trademark and Registered symbol with Regex Pin
Luc Pattyn2-Feb-12 9:05
sitebuilderLuc Pattyn2-Feb-12 9:05 
QuestionADO.net Pin
Amanjot1-Feb-12 12:09
Amanjot1-Feb-12 12:09 
Hi,
I have data in Access Database which I am filling in the DataGridView to QA/QC raw data downloaded from a climate station. I am having trouble updating the database using update command. I am using following steps:
1. Locating access database:
Private Sub AccessDataFileButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AccessDataFileButton.Click
OpenFileDialog2.Filter = "Microsoft Access File(*.mdb)|*.mdb|Microsoft Access File(*.accdb)|*.accdb|All files (*.*)|*.*"
OpenFileDialog2.Title = "Input Data File with Real-time Water Quality Time Series"
If OpenFileDialog2.ShowDialog = DialogResult.OK Then
accessDataFile = OpenFileDialog2.FileName
'MsgBox("accessFile= " & OpenFileDialog2.FileName)
Me.AccessFileTextBox.Text = accessDataFile

End If

End Sub

2. Filling DataGridView:
Sub fillDataGrid1()
' Read Access Table to find date and time of the last data
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & accessDataFile
Dim myConnection As OleDbConnection = New OleDbConnection
myConnection.ConnectionString = connString
myConnection.Open()

Dim inpTable As String = "rawClimateData" 'Access database table
Dim cmd As String = "Select * from " & inpTable '& " ORDER BY mdateTime"
Dim dbCmd As OleDbCommand = New OleDbCommand(cmd, myConnection)

' create a data adapter
Try
da = New OleDbDataAdapter(cmd, myConnection)
Catch ex As Exception ' Catch the error.
MsgBox(ex.ToString) ' Show friendly error message.
End Try

' create a new dataset
Dim table As New DataTable
myDataset = New DataSet()
Try
Me.da.Fill(table)
da.Fill(myDataset, inpTable)
Me.DataGridView1.DataSource = table
Catch ex As Exception
MsgBox(ex.ToString)
End Try
myConnection.Close()

End Sub
3. Updating database (update button)
Private Sub TryTry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles upDate.Click

Try

Me.da.Update(Me.myDataset.Tables("rawClimateData"))
Me.myDataset.AcceptChanges()

Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox("upDateComplete")
End Sub

In some examples I have seen connecting database file while Form is loading; however, I have an option of browsing the access database file.

I know it should be simple, however, I am not a pro. Therefore, any tips/help would be greatly appreciated.

Cheers,

Amanjot
AnswerRe: ADO.net Pin
Eddy Vluggen1-Feb-12 12:21
professionalEddy Vluggen1-Feb-12 12:21 

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.