what is this?
-
Hello, I am a newby to Visual Basic.. I have been having some problems with adding my data in my program. I am using Vb2005 and trying to use sotored procedure but h have error on run time message error : No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type This is what I have so far : Dim con As New System.Data.SqlClient.SqlConnection("Data Source=.;Initial Catalog=School;Integrated Security=True") Dim com As New System.Data.SqlClient.SqlCommand("proce_school_info", con) com.CommandType = CommandType.StoredProcedure com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text) com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text) com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text) com.Parameters.AddWithValue("@School_Address", Me.textBox4) com.Parameters.AddWithValue("@School_City", Me.textBox5) com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text) com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer)) com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer)) com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text) 'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text) com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text) com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text) com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text) con.Open() com.ExecuteNonQuery() con.Close()
Ahmed hassan
-
Hello, I am a newby to Visual Basic.. I have been having some problems with adding my data in my program. I am using Vb2005 and trying to use sotored procedure but h have error on run time message error : No mapping exists from object type System.Windows.Forms.TextBox to a known managed provider native type This is what I have so far : Dim con As New System.Data.SqlClient.SqlConnection("Data Source=.;Initial Catalog=School;Integrated Security=True") Dim com As New System.Data.SqlClient.SqlCommand("proce_school_info", con) com.CommandType = CommandType.StoredProcedure com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text) com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text) com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text) com.Parameters.AddWithValue("@School_Address", Me.textBox4) com.Parameters.AddWithValue("@School_City", Me.textBox5) com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text) com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer)) com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer)) com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text) 'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text) com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text) com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text) com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text) con.Open() com.ExecuteNonQuery() con.Close()
Ahmed hassan
hassanasp wrote:
com.Parameters.AddWithValue("@School_NameAr", Me.textBox1.Text) com.Parameters.AddWithValue("@School_NameEn", Me.textBox2.Text) com.Parameters.AddWithValue("@School_Edara ", Me.textBox3.Text) com.Parameters.AddWithValue("@School_Address", Me.textBox4) com.Parameters.AddWithValue("@School_City", Me.textBox5) com.Parameters.AddWithValue("@School_Nation ", Me.textBox6.Text) com.Parameters.AddWithValue("@School_Phone", CType(Me.textBox7.Text, Integer)) com.Parameters.AddWithValue("@School_Fax", CType(Me.textBox8.Text, Integer)) com.Parameters.AddWithValue("@School_Email", Me.textBox9.Text) 'com.Parameters.AddWithValue("@School_City", Me.textBox8.Text) com.Parameters.AddWithValue("@School_Country", Me.textBox10.Text) com.Parameters.AddWithValue("@School_Abbrev", Me.textBox11.Text) com.Parameters.AddWithValue("@School_FirstYear", Me.textBox12.Text)
I've bolded two lines above. You will notice that the lines in bold are missing something that the other lines have. That is the
.Text
property. And, by the way, naming your text boxes as textBox1, textBox2, etc. won't win you any friends. Please give them better names because the person that comes after you to maintain your code will curse you for it. And if you end up having to maintain the code you'll end up cursing yourself.
Upcoming FREE developer events: * Developer Day Scotland My website | blog