i'll attach a little snippet:

comd = New OdbcCommand("INSERT INTO news (new_title, new_content) VALUES (@newTitle, @newContent)", conn)
            
            comd.Parameters.Add("@newTitle", OdbcType.Text)
            comd.Parameters("@newTitle").Value = newsTitle.Text
            comd.Parameters.Add("@newContent", OdbcType.Text)
            comd.Parameters("@newContent").Value = FCKeditor1.Value
           

            conn.Open()
            comd.ExecuteNonQuery()
            Response.Redirect("default.aspx")

this code executes, and my database is updated, but the new_title and new_content fields are still NULL. i've tested by setting an error message label to the values of newsTitle.Text and comd.Parameters("@newTitle").Value, and the message label always shows the appropriate value... why aren't the values and my parameters connecting?

Recommended Answers

All 5 Replies

comd = new OleDbCommand();
comd.CommandText="INSERT INTO news (new_title, new_content) VALUES (@newTitle, @newContent";

comd.Connection=conn.getConnection();

comd.Parameters.AddWithValue("@vin",VIN);
comd.Parameters.AddWithValue("@price",price);
comd.Parameters.AddWithValue("@trandate",aDate);
comd.Parameters.AddWithValue("@trantype",transType);
            
comd.Connection.Open();
comd.ExecuteNonQuery();
comd.Connection.Close();
Response.Redirect("default.aspx")

i don't understand your reply.

comd.Parameters.Add("@newTitle", OdbcType.Text).Value = newsTitle.Text

try by this way and let us know !!

Try this. If it can't solve then post -complete- markup and code here.

comd = New OdbcCommand("INSERT INTO [news] (new_title, new_content) values(@newTitle, @newContent)", conn)
            
comd.Parameters.AddWithValue("@newTitle",newsTitle.Text)
comd.Parameters.AddWithValue("@newContent",newsContent.Text)

conn.Open()
comd.ExecuteNonQuery()
conn.Close()
Response.Redirect("default.aspx")

i don't understand your reply.

sorry, I was half asleep what adapost did. That was his solution anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.