CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_web_developer_2005_express Tags:
Item Type: NewsGroup Date Entered: 2/9/2007 7:17:24 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 10 Views: 54 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
11 Items, 1 Pages 1 |< << Go >> >|
roninuta
Asp.Net User
Noob to VWD 2005 - Insert from textbox into SQL DB2/9/2007 7:17:24 PM

0/0

I have followed all the tutorials and I think I have a pretty good grasp on how to get info from the SQL database running on my machine in the App Data directory. My question is simple and probably the answer is nested in the 148 pages of this very informative forum.

How do I take the 15 textbox fields worth of data and insert them into the SQL db? I am pretty familiar with general sql concepts (mysql, mssql, postgresql), but I have only been in this IDE for about a week now and I need to get my project up and running quickly. I am just unfamiliar with VB in general, but I do understand the object.method concept.

 I gathered that I need to make the insert statement part of the button click "event". I cannot find any good "starter" documentation on getting this process to work. I understand the grid and form and detail view really well and have tested my 2nd app with success, but it requires the db to be populated by a web front end. I have read a few MSDN links but they are not helping much, they just keep linking me back to grid and detal and form views.

 
Help? Please? Pretty Please?


- Chris
 

mkamoski
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/9/2007 9:53:23 PM

0/0

roninuta:

I have followed all the tutorials and I think I have a pretty good grasp on how to get info from the SQL database running on my machine in the App Data directory. My question is simple and probably the answer is nested in the 148 pages of this very informative forum.

How do I take the 15 textbox fields worth of data and insert them into the SQL db? I am pretty familiar with general sql concepts (mysql, mssql, postgresql), but I have only been in this IDE for about a week now and I need to get my project up and running quickly. I am just unfamiliar with VB in general, but I do understand the object.method concept.

 I gathered that I need to make the insert statement part of the button click "event". I cannot find any good "starter" documentation on getting this process to work. I understand the grid and form and detail view really well and have tested my 2nd app with success, but it requires the db to be populated by a web front end. I have read a few MSDN links but they are not helping much, they just keep linking me back to grid and detal and form views.


Help? Please? Pretty Please?


- Chris
 

This link...

http://www.WebLogicArts.com/DemoSqlServerDatabase01.aspx

...is a working sample with source code that shows one simple way to CreateOne/ UpdateOne/ DeleteOne/ RetrieveOne/ RetrieveAll using ASP.NET and SQL Sever 2000.

HTH.

Thank you.

-- Mark Kamoski

 


http://www.WebLogicArts.com
helsaint
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/11/2007 3:34:55 PM

0/0

Ok, there are two very simple ways you can do this.

1) Using the SQLDataSource object and after creating the connection using the GUI. You can find the SqlDataSource control in the toolbox. Although easy to use I don't like it too much, prefer writing SLQ statements on my own allows for more flexibility. However, to use the SqlDataSource object you are forced to create an SQL statement using the GUI, but this can be countermanded. So what I do is use the SQLDataSource object's SelectCommand and use its SelectCommand method to write my own SQL statement. Basically SQLDataSource1.SelectCommand = "Select * from whatever". To include textboxes, like in a search your SQL statement should look like this

"Select * from Table WHERE Table.Column = '" & textbox1.text & "'"

You can extrapolate to Insert and Update. 

2) Another way of using SQL in VWD2005E is to call ADODB objects. I find this the best method to do inserts and such. First you have to make a reference to the DLL, to do this you go to Website->Add Reference click on the COM tab and find Microsoft ActiveX Data Objects, pick one and click OK. To use ADODB you first declare it then set the connection string (I usually copy it from the SQLDataSource Object), and execute your sql command.

Dim Conn as ADODB.Connection

Conn.ConnectionString = "Provider..."

Conn.Execute(InsertCommand) 

 

Holler at me for any clarifications 

helsaint
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/11/2007 4:14:39 PM

0/0

I forgot, for 2 after Dim Conn as ADODB.Connection you have to put Conn = new ADODB.Connection
willydavidjr
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/11/2007 5:38:00 PM

0/0

You can try this one at your button submit click event using text1 as your control. 

 

Dim datasource As New SqlDataSource()

datasource.ConnectionString = ConfigurationManager.ConnectionStrings("YourConnectionString").ToString()

 

datasource.InsertCommandType = SqlDataSourceCommandType.Text

datasource.InsertCommand = "INSERT INTO YourTable (YourTableField) VALUES (@YourTableField)"

 

datasource.InsertParameters.Add(

"YourTableField", Text1.Text)

 

 


Willy David Jr

5th Year Bachelor of Technology Major in Information Technology Student - TUP

Software Engineering Technologist

Programming is a Passion, Software Development is an Adventure - willydavidjr
willydavidjr
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/11/2007 5:38:38 PM

0/0

You can try this one at your button submit click event using text1 as your control. 

 

Dim datasource As New SqlDataSource()

datasource.ConnectionString = ConfigurationManager.ConnectionStrings("YourConnectionString").ToString()

datasource.InsertCommandType = SqlDataSourceCommandType.Text

datasource.InsertCommand = "INSERT INTO YourTable (YourTableField) VALUES (@YourTableField)"

datasource.InsertParameters.Add(

"YourTableField", Text1.Text)

 

 

 

 


Willy David Jr

5th Year Bachelor of Technology Major in Information Technology Student - TUP

Software Engineering Technologist

Programming is a Passion, Software Development is an Adventure - willydavidjr
roninuta
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/12/2007 3:06:40 AM

0/0

this last example was awesome. It was implistic and really helped. I understand much more now. I new that I was going to have to use the parameters.add functionality. I think I am messing up on my connection string though and it is probably just not set correctly. I get an unhandled exception here is the error message:

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="App_Web_1cnoj4u7"
  StackTrace:
       at _Default.SendForm_Click(Object sender, EventArgs e) in D:\Documents and Settings\ronin\My Documents\Visual Studio 2005\WebSites\ADRequest\Default.aspx.vb:line 20
       at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
       at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

Here is line 20 - the connection string:

datasource.ConnectionString = ConfigurationManager.ConnectionStrings("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\adrequest.mdf;Integrated Security=True;User Instance=True").ToString()

 

I am using a built in SQLDB file that comes with VWD2005E, and the file is called adrequest.mdf, what am I missing here.

 

TIA,

Chris



 

willydavidjr
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/12/2007 5:36:30 PM

0/0

You are wrong with declaring with your connection string. Your connection string name must be like in my part:

phiwugdatasource.ConnectionString = ConfigurationManager.ConnectionStrings("phiwugConnectionString1").ToString()


To find the name of your connection string, try to do this, add a blank web form on your project, go to database explorer and go to the table of your database, click the table and drag and drop this to the blank web form. You will see that it will create a table on your blank web form and a control name SqlDataSource - SqlDataSource1. Click it then click the arrow next to it and you will see Configure Data Source and click it. Next a wizard will appear. The connection string name that will appear on the drop down list box is the connection string name you will write on it.

Be sure to mark as answer on the post you think that answers your question so that the poster will  have credit for it. Don't hesitate to inquire.

Best regards,

 


Willy David Jr

5th Year Bachelor of Technology Major in Information Technology Student - TUP

Software Engineering Technologist

Programming is a Passion, Software Development is an Adventure - willydavidjr
roninuta
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/12/2007 9:13:20 PM

0/0

This may be a silly question but given this code:

Dim datasource As New SqlDataSource()
        datasource.ConnectionString = ConfigurationManager.ConnectionStrings("connection2").ToString()
        datasource.InsertCommandType = SqlDataSourceCommandType.Text
        datasource.InsertCommand = "INSERT INTO ticket (sr) VALUES (@srnum)"
        datasource.InsertParameters.Add("srnum", TextBoxSRNum.Text)

is the data actually being posted to the DB or is the insert statement just being setup? Do I need to actually execute the statement through another line?

 TIA - Chris
 

roninuta
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/12/2007 9:18:21 PM

0/0

Nevermind

I just added datasurce.Insert() to the end of the event - that fixed it - thanks everyone for helping out!

 

 

- Chris 

willydavidjr
Asp.Net User
Re: Noob to VWD 2005 - Insert from textbox into SQL DB2/13/2007 9:57:31 PM

0/0

You can even add this one and put your datasource.insert() on a structured error handling procedure:

Dim

rowsaffected As Integer

Try

rowsaffected = datasource.Insert()

 

 

Catch ex As Exception

'TODO: Probably write a windows error log

 

Server.Transfer(

"error.aspx")     <---create a web form for error messages/site

Finally

datasource =

Nothing

 

End Try

 

If rowsaffected <> 1 Then

Server.Transfer(

"error.aspx")    <---create a web form for error messages/site

Else

Server.Transfer(

"success.aspx")     <----create a web form for success messages/site

 

End If
Willy David Jr

5th Year Bachelor of Technology Major in Information Technology Student - TUP

Software Engineering Technologist

Programming is a Passion, Software Development is an Adventure - willydavidjr
11 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
ng.asp-net-forum.visual_web_developer_2005_express/19 - Fix error ... Immediate Window in visual web developer TOTALLY MESSED UP???? 1, 9, 2/13/2007 10:16:56 PM. Noob to VWD 2005 - Insert from textbox into SQL DB ...
p2p.wrox.com Forums - Saving textbox data into Access CommandText = "INSERT INTO CharacterName (CharacterName) VALUES (@CharacterName) " ... Silverlight, Visual Web Developer 2005, Visual Web Developer 2008 ...
.NET Forum Page 20 - Bytes Site Map Can We Insert A Textbox Into Listbox In Asp.net · How to get values fron ... 2.0 Label with C# and Textfile html code in Visual Web Developer Express 2005 ...
TheMSsForum.com >> Asp >> Could some one help with this error on ... Of course I need to pass the value of my textbox into the XML file via an ..... save the currency symbol being used to the SQL Server 2005 backend database. ...
Configuring ASP.NET 2.0 Application Services to use SQL Server ... Step 2: Provision your SQL database with the ASP.NET schemas ...... Cannot insert the value NULL into column 'Column', table 'tempdb.dbo. ...
Casting DT_WSTR to integers in SSIS - SQL Server - coding C# stand alone app with db (noob) You may wanted to have a look at UserInstance feature of SQL Server Express edition. SQL Server 2005 Express ...
.NET ASP Page 13 - Bytes Site Map Reading the session information that is stored in SQL server. Downloading generated files · Loop in SQL .... Step-into Class Library from VWD 2005 problem . ...
TheMSsForum.com >> Dotnet >> Displaying currency in a ... So when the process runs, it writes out status messages to a textbox on the ... SQL Server Database I'm using VWD 2005 Express. I create a new SQL database. ...
Save ComboBox Values - MSDN Forums I forget to mention that I am using VB 2005 express and sql 2005 express. ... not saved into a db table. example:. First Name(TextBox). Last Name(TextBox) ...
.NET [Archive] - Page 10 - WebDeveloper.com NET change WebControl attributes · SQL permission error vb.net · String to GUID · Crystal Reports in ... [Asp.net/C#] Inserting date into a template field ...




Search This Site:










get applicationid

refresh logout bug

the file exist but can't delete on server (c#)

souce control or nant - which first

touch enabled web application woes

multiline text box only writes first line to db

vs2008 build error

visual web developer 2005 express edition beta

questions about the web.config file

error statuscode="403" not working

newbie question - carrying variables in a link?

ignoring a server error in webrequest

ie webcontrols source code

high bit characters and site internationalization (i18n)

validators not working on server

class to dll

add new module

is the system.web.caching.cache unique per session?

dotnetnuke 3.0 announcement...

loginview and cookieless session problem.

module customization question

display the calculator in asp.net

open source content management website

need thoughts about how to replace login with a custom module

sql server 2000 problem with vwd 2005 express

what is dnn?

dynamic menus feeding off eachother and a database

tabstrap---urgent questions!!

xml feed to classifieds

what do you guys see when going to dnnrocks?

 
All Times Are GMT