'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
ERROR: user-defined type not defined
Page 1 of 14 Replies - 779 Views - Last Post: 16 August 2012 - 03:08 AM
Replies To: ERROR: user-defined type not defined
#2
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.
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.
#3
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
#4
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
#5
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
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|