Hi,
Im using ASP.NET with back end as SQL Server. Im using VB language coding. here if in insert button im writing coding like this...

[ com = new SqlCommand("insert into emp values(" & Textbox1.Text & ", ' " & Textbox2.Text & " ', " & Textbox3.Text & " ", con) ]
[ con.Open() ]
[ com.ExecuteNonQuery() ]
[ Response.write " One record inserted " ]

here textbox1 and 3 contains onlu numeric values. and textbox2 has string value.
con is Sqlconnection. and com is SqlCommand declared in page load. i donno whats wrong with this?

The statement

con.Open()

has to come before

com = new SqlCommand("insert into emp values(" & Textbox1.Text & ", ' " & Textbox2.Text & " ', " & Textbox3.Text & " ", con)

This got to make it work.

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.