4 Replies - 1978 Views - Last Post: 16 August 2012 - 03:08 AM Rate Topic: -----

#1 TFPTECH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-August 12

ERROR: user-defined type not defined

Posted 15 August 2012 - 02:58 AM

'this is my code and the ERROR IS: user-defined type not defined, it has got red lines in it also
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdSave.Click()

Dim conn As New MySqlConnection
Dim cmd As New MySqlCommand
Dim SQL As String

' set up a remote data connection
' using the MySQL ODBC driver.
' change the connect string with your username,
' password, server name and the database you
' wish to connect to.
conn.CursorDriver = rdUserOdbc
conn.Connect = "uid=root;pwd=moses12;server=localhost:3306;" & _
"driver={MySQL ODBC 3.51 Driver};database=SRMS;"
conn.EstablishConnection
' set up a remote data object query
' specifying the SQL statement to run.
' let me try
Try
SQL = "insert into regstudent (n_Student, age, sex, nationality, p_birth, d_birth, religion, f_name, tel,occupation, w_place, F_address, m_name, tel2, occupation2, w_place2, F2_address, prev_school, Location, grade_attained, aggregates, code) values (?Text1, ?Text2, ?Text3, ?Text4, ?Text5, ?Text6', ?Text7, ?Text8, ?Text9, ?Text10, ?Text11, ?Text12, ?Text13, ?Text14, ?Text15, ?Text16, ?Text17, ?Text18, ?Text19, ?Text20, ?Text21, ?Text22)"

'MsgBox (SQL)
cmd.Connection = conn
cmd.CommandText = SQL
cmd.ExecuteNonQuery MessageBox.Show("A student has successfuly been registered", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterist)

Catch ex As Exception
MessageBox.Show("There was an error: " & ex.Message, "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

Is This A Good Question/Topic? 0
  • +

Replies To: ERROR: user-defined type not defined

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: ERROR: user-defined type not defined

Posted 15 August 2012 - 03:34 AM

Couple of points

1. Please use [CODE ] tags when posting code - it formats it and makes it easier to read.

2. This is VB.Net code, not VB6, so you've posted in the wrong forum.

3. Maybe you could show/tell us which lines are red or which line the error occurs on.
Was This Post Helpful? 0
  • +
  • -

#3 TFPTECH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-August 12

Re: ERROR: user-defined type not defined

Posted 16 August 2012 - 01:56 AM

'this is my code and the ERROR IS: user-defined type not defined, it has got red lines in it also
P[color="#FFFF00"]rivate Sub cmdSave_Click()[/color]
    
    Dim conn [color="#0000FF"]As New MySqlConnection[/color]
    Dim cmd As New MySqlCommand
    Dim SQL As String
  
    ' set up a remote data connection
    ' using the MySQL ODBC driver.
    ' change the connect string with your username,
    ' password, server name and the database you
    ' wish to connect to.
    conn.CursorDriver = rdUserOdbc
    conn.Connect = "uid=root;pwd=moses12;server=localhost:3306;" & _
        "driver={MySQL ODBC 3.51 Driver};database=SRMS;"
    conn.EstablishConnection
    ' set up a remote data object query
    ' specifying the SQL statement to run.
    ' let me try
    'Try
        SQL = "insert into regstudent (n_Student, age, sex, nationality, p_birth, d_birth, religion, f_name, tel,occupation, w_place, F_address, m_name, tel2, occupation2, w_place2, F2_address, prev_school, Location, grade_attained, aggregates, code) values (?Text1, ?Text2, ?Text3, ?Text4, ?Text5, ?Text6', ?Text7, ?Text8, ?Text9, ?Text10, ?Text11, ?Text12, ?Text13, ?Text14, ?Text15, ?Text16, ?Text17, ?Text18, ?Text19, ?Text20, ?Text21, ?Text22)"
            
        'MsgBox (SQL)
        cmd.Connection = conn
        cmd.CommandText = SQL
        cmd.ExecuteNonQuery MessageBox.Show("A student has successfuly been registered", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterist)
    
[color="#FF0000"]    'Catch ex As Exception
        'MessageBox.Show("There was an error: " & ex.Message, "Error", _
        'MessageBoxButtons.OK, MessageBoxIcon.Error)
    'End Try[/color]
End Sub


Was This Post Helpful? 0
  • +
  • -

#4 TFPTECH  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 15-August 12

Re: ERROR: user-defined type not defined

Posted 16 August 2012 - 02:08 AM

'this is my code and the ERROR IS: user-defined type not defined, it has got red lines in it also
'THIS LINE IS HIGHLIGHTED YELOW 
Private Sub cmdSave_Click()
    'THIS LINE IS HIGHLIGHTED BLUE 
    Dim conn As New MySqlConnection
    Dim cmd As New MySqlCommand
    Dim SQL As String
  
    ' set up a remote data connection
    ' using the MySQL ODBC driver.
    ' change the connect string with your username,
    ' password, server name and the database you
    ' wish to connect to.
    conn.CursorDriver = rdUserOdbc
    conn.Connect = "uid=root;pwd=moses12;server=localhost:3306;" & _
        "driver={MySQL ODBC 3.51 Driver};database=SRMS;"
    conn.EstablishConnection
    ' set up a remote data object query
    ' specifying the SQL statement to run.
    ' let me try
    'Try
        SQL = "insert into regstudent (n_Student, age, sex, nationality, p_birth, d_birth, religion, f_name, tel,occupation, w_place, F_address, m_name, tel2, occupation2, w_place2, F2_address, prev_school, Location, grade_attained, aggregates, code) values (?Text1, ?Text2, ?Text3, ?Text4, ?Text5, ?Text6', ?Text7, ?Text8, ?Text9, ?Text10, ?Text11, ?Text12, ?Text13, ?Text14, ?Text15, ?Text16, ?Text17, ?Text18, ?Text19, ?Text20, ?Text21, ?Text22)"
            
        'MsgBox (SQL)
        cmd.Connection = conn
        cmd.CommandText = SQL
        cmd.ExecuteNonQuery MessageBox.Show("A student has successfuly been registered", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterist)
    'THIS PART OF THE CODE IS RED 
    Catch ex As Exception
        MessageBox.Show("There was an error: " & ex.Message, "Error", _
        MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
End Sub


Was This Post Helpful? 0
  • +
  • -

#5 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: ERROR: user-defined type not defined

Posted 16 August 2012 - 03:08 AM

You don't appear to have a TRY, to go with your Catch Statement (or maybe it's the one you have commented out)?

This post has been edited by maj3091: 16 August 2012 - 03:08 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1