Hi guy,
I currently having problem saving my drawing into the sql database.
Can I get some help here pls.
my current codes:
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Public Class Page_2
' for GCS TABLE
Private value_GCS As Integer = 0
Dim value_Eyes As String = ""
.
.
.
Dim value_UrinaryCatheter As String = ""
' for freehand drawing
Dim mousePath As New System.Drawing.Drawing2D.GraphicsPath() 'declare a new Graphic path to follow the mouse movement
Dim myAlpha As Integer = 100 ' declare a Alpha variable
Dim myUserColor As New Color() 'this is a color the user selects
Dim myPenWidth As Single = 5 'set pen width variable
Private Sub Page_2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbl_Total.Text = CStr(value_GCS)
End Sub
Private Sub cbEyes4_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cbEyes4.MouseClick
cbEyes1.Checked = False
.
.
.
update_GCSTotal()
value_Eyes = "4"
End Sub
.
.
.
Private Sub cbVerbal4_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cbVerbal4.MouseClick
cbVerbal1.Checked = False
.
.
.
cbVerbal5.Checked = False
update_GCSTotal()
value_Verbal = "4"
Ebd Sub
Sub update_GCSTotal()
value_GCS = 0
If Me.cbEyes1.Checked Then
value_GCS += CInt(Me.cbEyes1.Text)
End If
.
.
.
.
.
If Me.cbMotor5.Checked Then
value_GCS += CInt(Me.cbMotor5.Text)
End If
If Me.cbMotor6.Checked Then
value_GCS += CInt(Me.cbMotor6.Text)
End If
lbl_Total.Text = CStr(value_GCS)
End Sub
Private Sub cbIntubationOral_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cbIntubationOral.MouseClick
cbIntubationOral.Checked = True
cbIntubationNasal.Checked = False
value_Intubation = "Oral"
End Sub
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim connAdd As New SqlConnection _
("Data Source=152.226.152.99\SQLEXPRESS,1433;" + "Initial Catalog=TAR;" + "User ID=Remote;" + "Password=123;")
'Client's IP: 152.226.152.76 Host's PC: 152.226.152.99
.
.
.
Dim mySQL As String
Try
connAdd.Open()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Open", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
mySQL = "insert into gcs (eyesOpen, verbal, motor, totalGcs) values ('" & Trim(value_Eyes) & "','" & Trim(value_Verbal) & "','" & Trim(value_Motor) & "','" & Trim(lbl_Total.Text) & "' ) "
Dim cmdAdd As New SqlCommand(mySQL, connAdd)
Try
cmdAdd.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error Query", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Dim Response As New Page_3()
Page_3.Show()
Me.Hide()
End Sub
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
Dim Response As New Page_1()
Page_1.Show()
Me.Hide()
End Sub
Private Sub pbBody_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbBody.MouseDown
If e.Button = MouseButtons.Left Then ' draw a filled circle if left mouse is down
mousePath.StartFigure() ' The L mouse is down so we need to start a new line in mousePath
End If
End Sub
Private Sub pbBody_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbBody.MouseMove
If e.Button = MouseButtons.Left Then ' draw a filled circle if left mouse is down
Try
mousePath.AddLine(e.X, e.Y, e.X, e.Y) 'Add mouse coordiantes to mousePath
Catch
MsgBox("No way, Hose!")
End Try
End If
pbBody.Invalidate() 'Repaint the PictureBox using the PictureBox1 Paint event
End Sub
Private Sub pbBody_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pbBody.Paint
' Here is where we do the actual painting
Try ' error trapping
myUserColor = (System.Drawing.Color.Black) 'You can remove this line and add a user selected color to
'change the value of myUserColor
myAlpha = 200 ' This will give the color a Alpha effect, you can set this to 255 if you want a full color
'*********************** NOTE ***********************************************
'The line below set the pen up with the ability to add user selected Alpha, Color and Penwidth
' A simpler, but less flexible solution would be to replace the line with the following code:
'Dim CurrentPen = New Pen(System.Drawing.Color.Black, myPenWidth)
'************ End Note ***************************
Dim CurrentPen As New Pen(Color.FromArgb(myAlpha, myUserColor), myPenWidth) 'Set up the pen
e.Graphics.DrawPath(CurrentPen, mousePath) 'draw the path! :)
Catch
' MsgBox("Not happening!")
End Try
End Sub
End Class
how do I do my saving and what is the datatype i used in my sql database for the images?
Thks