CODING METHOD

  • Thread starter Thread starter muhammadanzar
  • Start date Start date
M

muhammadanzar

Guest
HI

I do code in this way but i am not satisfy because it is foolish. how can i mange my code

private sub net()

try

Dim str As String = String.Empty
str = "'" + TextBox23.Text + "'"
Dim command As New SqlCommand("SELECT SupplierCode FROM supplier where SupplierName = " & str, connection)
Dim table As New DataTable
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(table)

Dim commands As New SqlCommand("SELECT SUM(NetValue) FROM dbo.purchase where Supplier = " & Val(table(0)(0)), connection)
Dim tables As New DataTable
Dim adapters As New SqlDataAdapter(commands)
adapters.Fill(tables)
'If tables(0)(0) = "" Then
' MessageBox.Show("No Record Found")
'End If
TextBox9.Text = tables(0)(0)

Catch ex As Exception
MsgBox(ex .Message)

Finally
End Try


end sub




look bold are repeat

2nd question

i write my each code sub or function in try catch block when one give error a list of dialog give error.

3r question

if i have wrong enter or mistake try catch stop me to insert data in database, but when i try 2nd time it give the following

which is given in pic1403819.png


MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

Continue reading...
 
Back
Top