Private Sub BackupDatabase(ByVal sqlQuery As String)
If Me.txtEnterFileName.Text.Equals("") Then
MessageBox.Show("Please Enter File Name First", "Error")
Return
End If
Dim objConnection As New OleDbConnection(frmMainForm.strConnectionString)
Try
Dim command As OleDbCommand = New OleDbCommand(sqlQuery, objConnection)
objConnection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
Dim oWrite As System.IO.StreamWriter
oWrite = File.AppendText(Me.txtEnterFileName.Text)
While reader.Read()
DOES THE O NEED TO BE HERE; WILL IT WORK WITHOUT THE O i.e. oWrite? (this line not part of code)
oWrite.WriteLine(reader.GetString(0))
oWrite.WriteLine(reader.GetString(1))
oWrite.WriteLine(reader.GetInt32(2))
oWrite.WriteLine(reader.GetInt32(3))
End While
oWrite.Close()
objConnection.Close()
Catch ex As Exception
Console.WriteLine("Error while backing up " + ex.Message + ex.StackTrace) 'not sure what this means
End Try
End Sub
What does this mean?Need help adding comments to this code so that someone will know what
Page 1 of 1
8 Replies - 2191 Views - Last Post: 17 May 2008 - 07:03 AM
#1
What does this mean?
Posted 14 May 2008 - 07:55 PM
Replies To: What does this mean?
#2
Re: What does this mean?
Posted 14 May 2008 - 08:54 PM
So in other words you're looking for someone to comment this code (that you got from somewhere, otherwise you'd know what it does) so that you don't have to put forth any effort for the assignment?
#3
Re: What does this mean?
Posted 14 May 2008 - 11:47 PM
I hate it when people just ask for the answer flat out, that ruins the fun and the learning all at the same time. I guess people can give you hints and maybe tell you, "Hey you're on the right track." But after that you should be on your own to at least try to figure it out.
#4
Re: What does this mean?
Posted 16 May 2008 - 08:40 PM
Need to add comments to this code so that someone will know what it is doing.
-----------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------
Dim oWrite As System.IO.StreamWriter
oWrite = File.AppendText(Me.txtEnterFileName.Text)
While reader.Read()
oWrite.WriteLine(reader.GetString(0))
oWrite.WriteLine(reader.GetString(1))
oWrite.WriteLine(reader.GetInt32(2))
oWrite.WriteLine(reader.GetInt32(3))
End While
oWrite.Close()
objConnection.Close()
Catch ex As Exception
Console.WriteLine("Error while backing up " + ex.Message + ex.StackTrace) 'REALLY DON'T GET THIS LINE
End Try
#5
Re: What does this mean?
Posted 16 May 2008 - 08:43 PM
NEED TO ADD COMMENTS TO THIS SO THAT SOMEONE READING IT WILL KNOW WHAT IT IS DOING.
Also have to remove what is not needed Please help..thanks in advance
---------------------------------------------------------------------------------------------------------------------
Also have to remove what is not needed Please help..thanks in advance
---------------------------------------------------------------------------------------------------------------------
Private Function insertIntoDatabase(ByVal fname As String, ByVal state As String, ByVal sales As Int32, ByVal salesPrev As Int32) As Int32
Dim objConnection As New OleDbConnection(frmMainForm.strConnectionString)
Dim num As Int32 = 0
Try
Dim sqlQuery As String = "insert into Customer Values ('" & fname & "' , '" & state & "' , " & sales & ", " & salesPrev & " ); "
Dim sqlQuery As String = "insert into Customer Values (" & fname & " , " & state & " , " & sales & ", " & salesPrev & " ); "
Dim command As OleDbCommand = New OleDbCommand(sqlQuery, objConnection)
objConnection.Open()
num = command.ExecuteNonQuery()
objConnection.Close()
Catch ex As Exception
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
Dim d As Date = DateTime.Now
oWrite = File.AppendText("ERROR_" & d.Year & d.Month & d.Day & "_" & d.Hour & d.Minute & d.Second & ".txt")
oWrite.WriteLine(fname)
oWrite.Close()
Console.WriteLine(ex.Message)
Console.WriteLine(ex.StackTrace)
End Try
Return num
End Function
#6
Re: What does this mean?
Posted 16 May 2008 - 08:47 PM
so.....add comments to it. What do you want us to do ?
Add them for you?
Add them for you?
#7
Re: What does this mean?
Posted 16 May 2008 - 08:48 PM
If you wrote the code. Which is doesn't appear that you did, BUT if you did you should know what it does and be able to comment it yourself. My guess is you didn't write it yourself
Please you code tags when posting code
Please you code tags when posting code
#8
Re: What does this mean?
Posted 16 May 2008 - 08:54 PM
Sorry, kiddo, but we won't do your homework for you.
#9
Re: What does this mean?
Posted 17 May 2008 - 07:03 AM
Moved To VB.NET
Wow, you just got threads all over the place asking others to do your work, don't you? Well now they're all merged
Wow, you just got threads all over the place asking others to do your work, don't you? Well now they're all merged
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|