i came up with a quite annoying problem in inserting data into the database in vb.net using the textfields. i tried out with many different ways,but could not sort out this problem.
i used datatables,dataadapters,datasets.Plz if anyone can help me out.
The condition is :
i am using four tables. and in one table the primary key which is auto increment is a FK in the table that i actually use for storing the inserted the data in the textfields.
here is where i am getting the problem:
cn.Open()
str = "insert into tbl_emps(empname,empsal,desgid) values('" & t1.Text & "'," & (t2.Text) & "," & (t3.Text) & ")"
da.Fill(ds, "tbl_emp")
dt.TableName = "tbl_emp"
cn.Close()
is it correct.
2nd Type
cn.Open()
str = "insert into tbl_emps(empname,empsal,desgid) values('"
& t1.Text & "'," & (t2.Text) & "," & (t3.Text) & ")"
cmd.commandtext=str
cmd.executenonquery()
The problem that i get is :
ExecuteReader: CommandText property has not been initialized