我是新的vb.net,sql甚至记录在phpmyadmin中的数据。当我使用我的界面添加记录时,我检查了我的phpmyadmin,它指示表中有一个条目,表示我的vb.net和phpmyadmin已连接,但值返回NULL。我怎样才能让它不是NULL?相反,记录所需的数据?vb.net保存在phpmyadmin空值返回
这是我的代码:
Dim ServerString As String = "Server=localhost; database=patientinfo;user id=root;password="
Dim SQLConnection As New MySqlConnection()
Public Sub SaveInfos(ByRef SQLStatement As String)
Dim cmd As MySqlCommand = New MySqlCommand
With cmd
.CommandText = SQLStatement
.CommandType = CommandType.Text
.Connection = SQLConnection
.ExecuteNonQuery()
End With
SQLConnection.Close()
'MsgBox("Successfully Added!")
MsgBox("Successfully Saved")
Me.Visible = False
Mainform.Show()
SQLConnection.Dispose()
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Try
'===========================Add New Patient========================================
bednumber = txtbednum.Text
patient_name = txtName.Text
patient_age = Convert.ToInt32(txtAge.Text)
date_of_confinement = Date.Parse(dtpDate.Value)
type_of_sickness = txtSickness.Text
type_of_IV_fluid = txtFluid.Text
number_of_bottles = Convert.ToInt32(txtBottle.Text)
drop_rate = Convert.ToInt32(txtDrop.Text)
'To check if all values have been filled up
If patient_name = "" Or patient_age = "" Or date_of_confinement = "" _
Or type_of_sickness = "" Or type_of_IV_fluid = "" Or number_of_bottles = "" Or drop_rate = "" _
Then
MsgBox("Please Complete All the Required Fields")
Else
Dim SQLStatement As String = "INSERT INTO patient(bednumber, name, age, date_of_confinement,type_of_sickness, type_of_IV_fluid, number_of_bottles, drop_rate) VALUES(@bednumber, @name, @age, @date_of_confinement, @type_of_sickness, @type_of_IV_fluid, @number_of_bottles, @drop_rate)"
SaveInfos(SQLStatement)
这就是我的表看起来像在phpMyAdmin:
http://i1182.photobucket.com/albums/x454/catherinefbalauro/Untitled.png
任何帮助,将不胜感激。谢谢! :)
已经解决了由我:))[CLOSED] – Mineko 2012-07-26 01:21:43