944,175 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 32383
  • VB.NET RSS
Nov 13th, 2006
0

how to insert data into the database in vb.net using textfields.

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Unverified User
tirumal is offline Offline
3 posts
since Nov 2006
Jul 25th, 2007
0

Re: how to insert data into the database in vb.net using textfields.

Add to the code has dim dr as (sql.datareader=cmd.executereader)i hope this statement --works out,,,,
Reputation Points: 5
Solved Threads: 1
Junior Poster in Training
preetham.saroja is offline Offline
82 posts
since Jun 2007
Jul 27th, 2007
0

Re: how to insert data into the database in vb.net using textfields.

You have to indicate what type of command you are using. This could be got from the commandtype.property. Indicate that it is text and not a storedproc or others. It should work.

Get back if it doesn't
Reputation Points: 215
Solved Threads: 6
Posting Whiz in Training
jamello is offline Offline
219 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Desktop Short Cut
Next Thread in VB.NET Forum Timeline: IF statement in a varible





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC