Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.Odbc
- Imports System.Data.SqlClient
- Public Class OrderForm
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- medID.Text = Request.QueryString("mediaID")
- MEDCATPR.Text = Request.QueryString("MEDCATPR")
- medNM.Text = Request.QueryString("medNM")
- mediaLink.Attributes.Add("src", Request.QueryString("mediaLink"))
- End Sub
- Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
- placeOrder()
- End Sub
- Public Function getMediaValue(ByVal value As String) As String
- Dim parameter As String = Nothing
- MsgBox("returning " + value)
- Select Case value
- Case "medID"
- parameter = medID.Text
- Case "MEDCATPR"
- MsgBox("stupid") ' = MEDCATPR.Text
- Case "medNM"
- parameter = medNM.Text
- Case "mediaText"
- parameter = mediaText.Text
- Case Else
- parameter = "didn't work"
- End Select
- MsgBox(parameter)
- Return parameter
- End Function
- '
- 'This should go in the order class, but I can't get it to work
- '
- Public Sub placeOrder()
- Try
- 'Dim conn = "Driver={MySQL ODBC 5.1 Driver};Server='173.15.24.2';Database=mydb; User=root;Password=password;Option=3;"
- Dim conn As String = "Driver={MySQL ODBC 5.1 Driver};Server=173.15.24.2;Database=wsc; User=root;Password=Viku1988!;Option=3;"
- Dim dbConn2 As New OdbcConnection(conn)
- dbConn2.Open()
- 'Dim sql As String = "INSERT INTO order (medID, ordID, contNum, empID, ordTO, medQuan, mediaText) VALUES(@medID,@ordID,@contNum,@empID,@ordTO,@medQuan, @mediaText)"
- Dim sql As String = "INSERT INTO order (`medID`, `ordID`, `contNum`, `medQuan`, `mediaText`) VALUES('a',1,2,2, 'abc')"
- 'put data values in correct format
- Dim orderID As Integer = 1010101
- Dim price As Integer = CInt(MEDCATPR.Text)
- Dim quantity As Decimal = CDec(medQuan.SelectedValue)
- Dim total As Decimal = price * quantity
- Dim contNum As Integer = 11
- Dim empID As Integer = 22
- 'MsgBox(mediaText.Text)
- 'Dim sql As String = "INSERT INTO order (medID, ordID, contNum, medQuan, mediaText) VALUES('" + medID.Text + "','" + orderID.ToString + "','" + contNum.ToString + "','" + quantity.ToString + "', '" + mediaText.Text + "')"
- Dim command As New OdbcCommand
- command.Connection = dbConn2
- command.CommandText = sql
- 'command.Parameters.AddWithValue("medID", medID.Text)
- 'command.Parameters.AddWithValue("ordID", orderID)
- 'command.Parameters.AddWithValue("contNum", contNum)
- 'command.Parameters.AddWithValue("empID", empID)
- 'command.Parameters.AddWithValue("ordTO", total)
- 'command.Parameters.AddWithValue("medQuan", quantity)
- 'command.Parameters.AddWithValue("mediaText", mediaText.Text)
- 'command.Parameters.Add("@medID", OdbcType.NVarChar, 25).Value = getMediaValue("medID")
- 'Dim orderID As Integer = CInt(getMediaValue("ordID"))
- 'command.Parameters.Add("@ordID", OdbcType.Int, 8).Value = orderID
- ''not sure about these
- 'command.Parameters.Add("@contNum", OdbcType.Int, 10).Value = 123456
- 'command.Parameters.Add("@empID", OdbcType.Int, 8).Value = 11111111
- 'Dim price As Decimal = CDec(getMediaValue(MEDCATPR.Text))
- 'Dim quantity As Decimal = CDec(getMediaValue(medQuan.SelectedValue))
- 'Dim total As Decimal = price * quantity
- 'command.Parameters.Add("@ordTO", OdbcType.Decimal, 3, 2).Value = total
- 'command.Parameters.Add("@medQuan", OdbcType.Int, 11).Value = quantity
- command.ExecuteNonQuery()
- 'Dim reader As OdbcDataReader = command.ExecuteReader
- MsgBox("Your order was placed successfully")
- Catch ex As Exception
- 'MsgBox("Your order was not able to placed at this time")
- MsgBox(ex.Message)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement