Inserting NULLS into MySQL database.http://forums.asp.net/t/383331.aspx/1?Inserting+NULLS+into+MySQL+database+Mon, 03 Nov 2003 12:42:09 -0500383331383331http://forums.asp.net/p/383331/383331.aspx/1?Inserting+NULLS+into+MySQL+database+Inserting NULLS into MySQL database. Hi all, I'm completely new to this so please excuse if my code is all over the place - I've tried to copy and modify as much as possible. I am trying to create a website that will display the data from one database (mysql) and then return some of the data and some more user input to a second database (also mysql) the reason for using two databases is unimportant. The code below works fine in terms of connections, but falls over in that it inserts new records where all field are NULL (not the input that I wanted them to be). Any help would be greatly appreciated. Regards, Sam. ' Code from here down.... Function AddData(ByVal first As String, ByVal last As String, ByVal urno As String, ByVal phonno As String) As Integer Dim connectionString As String = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;USER=root;PASSWORD=password;Trusted_connection=true;DATABASE=database02;" Dim dbConnection As OdbcConnection = New OdbcConnection(connectionString) Dim queryString As String = "INSERT INTO patient (fname, lname, ur, phone) VALUES (@FirstName, @LastName, @ur, @phone)" Dim dbCommand As OdbcCommand = New OdbcCommand dbCommand.CommandText = queryString dbCommand.Connection = dbConnection dbCommand.Parameters.Add("@FirstName", DbType.String).Value = first dbCommand.Parameters.Add("@LastName", DbType.String).Value = last dbCommand.Parameters.Add("@ur", DbType.String).Value = urno dbCommand.Parameters.Add("@phone", DbType.String).Value = phonno Dim rowsAffected As Integer = 0 dbConnection.Open Try rowsAffected = dbCommand.ExecuteNonQuery Finally dbConnection.Close End Try End Function Sub Button3_Click(sender As Object, e As EventArgs) If Page.IsValid = False Then Exit Sub End If Dim first As String Dim last As String Dim urno As String Dim phonno As String first = Server.HtmlEncode(firstname.Text) last = Server.HtmlEncode(lastname.text) urno = Server.HtmlEncode(ur.text) phonno = Server.HtmlEncode(phone.text) Try AddData(first, last, urno, phonno) Catch Response.Write ("Didn't Work") End Try End Sub 2003-11-03T12:42:09-05:00