0

please help to connect our vb.net forms with database.
I know make forms and connecting that forms.i know creating tables in database and inserting values in it.no idea about connecting forms and data base.pls help me.we use sql server 2008.i am a beginner in vb.net

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by M.Waqas Aslam
0

Sir
We designed a login form. WE want to enter username and password and store those in a table. How can we do that?

0

hello ! you can do it like this

'first import system.data.sqlclient then
dim myCon as new sqlconnection("your connection string")
dim cmd as new sqlcommand
myCon.open()
cmd.connection=myCon
cmd.commandtext="insert into tablename (field1,field2,field3) values (@field1,@field2,@field3)"
cmd.parameter.add("@field1",______).value = txtvalue1.text 'in place of ___ write datatype of your field in your db.
cmd.parameter.add("@field2",______).value = txtvalue2.text
cmd.parameter.add("@field3",______).value = txtvalue3.text'if you have datatype of your field in your db is int , decimal , bigint, etc then use val(txtvalue.text)
cmd.executenonquery()
myCon.close

this will insert your data in your table . well i write this code here , so may be there are some spelling mistakes , check them by your own self .
If your prob is solved please mark this thread solved .

Regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.