User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 401,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,385 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 559 | Replies: 3
Reply
Join Date: Apr 2007
Posts: 253
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

need u r help

  #1  
May 7th, 2007
hi everyone,
iam a newbie in asp.net.even it sounds silly doubt to u ,plz help me.i want parameters in a sql query to insert a record.i wrote the program like this,but iam not able to insert the data.so,plz say my mistake .
Dim
str AsString

con = New SqlConnection("user id=sa;password=;data source=charan;database=master")
command = New SqlCommand(str, con)
command.Parameters.Add(New SqlParameter(" @empid ", TextBox1.Text))
command.Parameters.Add(New SqlParameter("@empname", TextBox2.Text))
command.Parameters.Add(New SqlParameter("@salary", TextBox3.Text))
command.Parameters.Add(New SqlParameter("@comm", TextBox4.Text))
str = "insert into employees(empid,empname,salary,comm)values (@empid,@empname,@salary,@comm)"
con.Open()
command.ExecuteNonQuery()
da = New SqlDataAdapter("select distinct * from employees ", con)
da.Fill(ds, "employees")
GridView1.DataSource = ds
GridView1.DataBind()
con.Close()
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2005
Location: Mostar
Posts: 88
Reputation: ManicCW is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 10
ManicCW's Avatar
ManicCW ManicCW is offline Offline
Junior Poster in Training

Re: need u r help

  #2  
May 7th, 2007
What is the error that you get?
Reply With Quote  
Join Date: Apr 2007
Posts: 253
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 9
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

Re: need u r help

  #3  
May 8th, 2007
hi,
iam not getting any error but iam not able insert my record.any help appreciated
Reply With Quote  
Join Date: Nov 2005
Location: Mostar
Posts: 88
Reputation: ManicCW is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 10
ManicCW's Avatar
ManicCW ManicCW is offline Offline
Junior Poster in Training

Re: need u r help

  #4  
May 8th, 2007
data source=charan;database=master

What is this?
You are updating master database.

This is no good.
I recommend tutorials for beginners.

I the meantime, try using this:

Server=SERVER_NAME;Database=DATABASE_NAME;Trusted_Connection=True
Last edited by ManicCW : May 8th, 2007 at 7:37 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 3:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC