What does this mean?

Need help adding comments to this code so that someone will know what

Page 1 of 1

8 Replies - 2713 Views - Last Post: 17 May 2008 - 07:03 AM Rate Topic: -----

#1 schooler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-May 08

What does this mean?

Post icon  Posted 14 May 2008 - 07:55 PM

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


Is This A Good Question/Topic? 0
  • +

Replies To: What does this mean?

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

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?
Was This Post Helpful? 0
  • +
  • -

#3 Tastybrownies  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 13-May 08

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.
Was This Post Helpful? 0
  • +
  • -

#4 schooler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-May 08

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

Was This Post Helpful? 0
  • +
  • -

#5 schooler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 13-May 08

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
---------------------------------------------------------------------------------------------------------------------
  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

Was This Post Helpful? 0
  • +
  • -

#6 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

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?
Was This Post Helpful? 0
  • +
  • -

#7 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

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 :P


Please you code tags when posting code
Was This Post Helpful? 0
  • +
  • -

#8 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: What does this mean?

Posted 16 May 2008 - 08:54 PM

Sorry, kiddo, but we won't do your homework for you.
Was This Post Helpful? 0
  • +
  • -

#9 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

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 :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1