Click here to Skip to main content
15,888,802 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
QuestionCreate a unique Id for each row of table Pin
Seema Bawa1-Feb-12 8:19
Seema Bawa1-Feb-12 8:19 
AnswerRe: Create a unique Id for each row of table Pin
Simon_Whale1-Feb-12 12:16
Simon_Whale1-Feb-12 12:16 
JokeRe: Create a unique Id for each row of table Pin
Eddy Vluggen1-Feb-12 12:30
professionalEddy Vluggen1-Feb-12 12:30 
GeneralRe: Create a unique Id for each row of table Pin
Simon_Whale1-Feb-12 21:58
Simon_Whale1-Feb-12 21:58 
AnswerRe: Create a unique Id for each row of table Pin
RobCroll1-Feb-12 16:14
RobCroll1-Feb-12 16:14 
QuestionCreate a unique Id for Rows Pin
Seema Bawa1-Feb-12 7:58
Seema Bawa1-Feb-12 7:58 
AnswerRe: Create a unique Id for Rows Pin
Eddy Vluggen1-Feb-12 8:16
professionalEddy Vluggen1-Feb-12 8:16 
QuestionOptional parameters cannot have structure types Pin
Clark Kent1231-Feb-12 5:53
professionalClark Kent1231-Feb-12 5:53 
AnswerRe: Optional parameters cannot have structure types Pin
Eddy Vluggen1-Feb-12 6:34
professionalEddy Vluggen1-Feb-12 6:34 
GeneralRe: Optional parameters cannot have structure types Pin
Clark Kent1231-Feb-12 7:16
professionalClark Kent1231-Feb-12 7:16 
GeneralRe: Optional parameters cannot have structure types Pin
Eddy Vluggen1-Feb-12 7:41
professionalEddy Vluggen1-Feb-12 7:41 
QuestionFrom Variant/double() to Double() Pin
PozzaVecia31-Jan-12 11:54
PozzaVecia31-Jan-12 11:54 
AnswerRe: From Variant/double() to Double() Pin
Eddy Vluggen1-Feb-12 9:47
professionalEddy Vluggen1-Feb-12 9:47 
GeneralRe: From Variant/double() to Double() Pin
PozzaVecia1-Feb-12 10:28
PozzaVecia1-Feb-12 10:28 
AnswerRe: From Variant/double() to Double() Pin
Wes Aday1-Feb-12 10:07
professionalWes Aday1-Feb-12 10:07 
GeneralRe: From Variant/double() to Double() Pin
PozzaVecia1-Feb-12 10:30
PozzaVecia1-Feb-12 10:30 

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.