15-11-12, 10:23 PM
تم الامر معي لكن بالتعديلات التالية:
كود :
Dim con As New SqlConnection("Server=.\sqlexpress;Database=medo;Trusted_Connection=True;")كود :
Try
Dim strs As String = "INSERT INTO odo_mota (odo_mot_name) VALUES ('" & TextBox1.Text & "')"
Dim cm As New SqlCommand(strs, con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
cm.ExecuteNonQuery()
If con.State = ConnectionState.Open Then
con.Close()
End If
MsgBox("string saved successfuly", MsgBoxStyle.Information, "Done")
Catch ex As Exception
If con.State = ConnectionState.Open Then
con.Close()
End If
MsgBox(ex.Message)
MsgBox("Erorr")
End Tryولعرض ماتم حفظه
كود :
Dim cm As New SqlCommand("select * from odo_mota", con)
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim dr As SqlDataReader
dr = cm.ExecuteReader
If dr.Read Then
TextBox2.Text = dr.Item("odo_mot_name")
End If