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

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2006
Posts: 3
Reputation: tirumal is an unknown quantity at this point 
Solved Threads: 0
tirumal's Avatar
tirumal tirumal is offline Offline
Newbie Poster

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

 
0
  #1
Nov 13th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 82
Reputation: preetham.saroja is an unknown quantity at this point 
Solved Threads: 1
preetham.saroja's Avatar
preetham.saroja preetham.saroja is offline Offline
Junior Poster in Training

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

 
0
  #2
Jul 25th, 2007
Add to the code has dim dr as (sql.datareader=cmd.executereader)i hope this statement --works out,,,,
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 216
Reputation: jamello is an unknown quantity at this point 
Solved Threads: 6
jamello's Avatar
jamello jamello is offline Offline
Posting Whiz in Training

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

 
0
  #3
Jul 27th, 2007
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC