Inserting Data From TextBox

Feb 8, 2006

Hi,

I'm a newbie to to asp.net. I have been trying to get this done but have no idea how to go about to do it. I am using Visual Studio Express 2005 and SQL Server Express 2005.

I have a database "RECORDS" and a table "NAME" with columns "NAMEID - int" and "NAMERECORDS - varchar(50)"

I opened new website asp.net using vb. In the default I have one textbox (textbox1) and button (button1).

I wish to insert a new NAME to the database whenever I click the Button1. I have created the INSERT command but unsure how to code it. I appreciate anyone can show me how to insert to the database whatever is being typed in the textbox whenever I click the button1. Thanks in advance.

 

 

 

View 3 Replies


ADVERTISEMENT

Inserting Data To Table From Textbox

Jun 17, 2008

Hello all....
I am trying to submit data from a form(textbox) to a sql table. but I am getting an error message "NullReferenceException was unhandled by user code" Can any help me with this? This is my code inProtected Sub btnSubmit_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim cnstr As String = ConfigurationManager.ConnectionStrings("ConnectionString").ToString()Dim pa1 As Data.SqlClient.SqlParameter = New Data.SqlClient.SqlParameter("Keyword", Data.SqlDbType.VarChar, 50, Data.ParameterDirection.Input)
pa1.Value = Keyword.Text
SqlHelper.ExecuteNonQuery(cnstr, Data.CommandType.StoredProcedure, "spNewRec", pa1)
 
Thanks in advance...

View 4 Replies View Related

Need Help Inserting Data Into Table With Sql Insert Into Using Textbox Values

Oct 6, 2007

the error message I get is
{"Object reference not set to an instance of an object."}
and it points to <  Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text >   
 this is my code":
 Protected Sub TickMastBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TickMastBtn.Click
REM Collect variablesDim Tickr As String = CType(FindControl("TickerTextbx"), TextBox).Text
Dim Comp As String = CType(FindControl("CoTextbx"), TextBox).TextDim Exch As String = CType(FindControl("ExchTextbx"), TextBox).Text
REM Create connection and command objectsDim cn As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:Program FilesMicrosoft SQL ServerMSSQL.1MSSQLDataVTRADE.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")Dim cmd As New SqlCommand
cmd.Connection = cn
REM Build our parameterized insert statementDim sql As New StringBuilder
sql.Append("INSERT INTO TickerMaster ")sql.Append("(Ticker,Company,Exchange,) ")sql.Append("VALUES (@Tickr,@Comp,@Exch,)")
cmd.CommandText = sql.ToString
REM Add parameter values to command
REM Parameters used to protect DB from SQL injection attacksWith cmd.Parameters
.Add("Tickr", SqlDbType.Int).Value = Tickr.Add("Comp", SqlDbType.VarChar).Value = Comp
.Add("Exch", SqlDbType.VarChar).Value = Exch
End With
REM Now execute the statement
cn.Open()
cmd.ExecuteNonQuery()
cn.Close()
End Sub

View 3 Replies View Related

Inserting TextBox Values To Database Using SqlDataSource.Insert Method

Oct 25, 2006

Hi, it is few days I posted here my question, but received no answer. Maybe the problem is just my problem, maybe I put my question some strange way. OK, I try to put it again, more simply. I have few textboxes, their values I need to transport to database. I set SqlDataSource, parameters... and used SqlDataSource.Insert() method. I got NULL values in the database's record. So I tried find problem by using Microsoft's sample code from address http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.insert.aspx. After some changes I tried that code and everything went well, data were put into database. Next step was to separate code beside and structure of page to two separate files followed by new test. Good again, data were delivered to database. Next step: to use MasterPage, very simple, just with one ContentPlaceHolder. After this step the program stoped to deliver data to database and delivers only NULLs to new record. It is exactly the same problem which I have found in my application. The functionless code is here:http://forums.asp.net/thread/1437716.aspx I cannot find any answer this problem on forums worldwide. I cannot believe it is only my problem. I compared html code of two generated pages - with maserPage and without. There are differentions in code in ids' of input fields generated by NET.Framework:Without masterpage:<input name="NazevBox" type="text" id="NazevBox" /><span id="RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="CodeBox" type="text" id="CodeBox" /><span id="RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="Button1" /> With masterpage:<input name="ctl00$Obsah$NazevBox" type="text" id="ctl00_Obsah_NazevBox" /><span id="ctl00_Obsah_RequiredFieldValidator1" style='color:Red;visibility:hidden;'>Please enter a company name.</span><p><input name="ctl00$Obsah$CodeBox" type="text" id="ctl00_Obsah_CodeBox" /><span id="ctl00_Obsah_RequiredFieldValidator2" style='color:Red;visibility:hidden;'>Please enter a phone number.</span><p><input type="submit" name="ctl00$Obsah$Button1" value="Insert New Shipper" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$Obsah$Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" id="ctl00_Obsah_Button1" />In second case ids' of input fields have different names, but I hope it is inner business of NET.Framework.There must be something I haven't noticed, maybe NET's bug, maybe my own. Thanks for any suggestion.

View 2 Replies View Related

How To Refer To Report Textbox Values In Another Textbox

May 24, 2007

I want to add up the values in a couple of text boxes in another textbox. How do I refer to the textboxes?



fields!textbox1.value doesn't work..what does?

View 1 Replies View Related

Easiest Way To Get Data From Sql To Textbox

Jun 17, 2008

Hi I have a situation where i have a drop down list. The user selects a value from it and then a query behind the scenes is generated based on the value from the list. I want the result of the query to be diplayed in the textbox.I've checked a few examples but i don't really have a good understanding of how to generate this query and get the results to the textbox. I think you use the SQLDATASOURCE but still need some help...Can anyone help? Thanks. 

View 4 Replies View Related

How To Retrieve Data From Db And Put At Textbox?

Oct 26, 2006

hi there...i want to know how to get a specific data from a database and put it in a label? Like an example i have created a database that have "username", "account number"..example i want to put the account number of the username "kevin" into a text box (vs 2005)..

View 2 Replies View Related

Data Alignment In Textbox

Feb 26, 2007

Hi All,
I am working on a report, in this report a textbox is present, which is expected to show string. This string length is larger than what textbox can accommodate in single line. I want this textbox to show only right part of the string in case it can accommodate full string.
After using the right alignment I assumed it would do show, however it does not work like that. It always shows the left part of string in case, string is bigger than width of textbox.
Restriction from design:
1. Cannot increase the width of textbox.
2. Cannot use the Can Grow = true to show string in multiple lines.

Below is the example of my issue:
Say there is a string: "Microsoft SQL Server Reporting Services".
because the textbox width is not sufficient to see full string, I want to "Reporting Service". Which is of same size which column can accommodate. So I used Right alignment in textbox. however text box shows "Microsoft SQL Server". So, is there a solution to see required text in the textbox.

View 1 Replies View Related

Using A Textbox To Send Data To A Database?

Jan 18, 2007

i currently have multiple textboxes which input data, i'm wanting the textbox details to be sent to a database, here's how one of the textboxes look: <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' Visible="False" Width="300px"></asp:TextBox>
the sqldatasource:<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CommunityDirConnectionString %>" InsertCommand="INSERT INTO email(Name, Department, Email, Subject, Body) VALUES (@Name, @Department, @Email, @Subject, @Body)" SelectCommand="SELECT email.* FROM email"><InsertParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Department" /><asp:Parameter Name="Email" /><asp:Parameter Name="Subject" /><asp:Parameter Name="Body" /></InsertParameters></asp:SqlDataSource>
i'm wanting it to fire once the user selects a button, but i'm not sure what code needs to be placed behind the button?
 

View 4 Replies View Related

Move Data From SqlDataSource To A TextBox

Apr 9, 2007

I have a DataReader on a web page: <asp:SqlDataSource ID="ChangeInfoRecord" runat="server" ConnectionString..........
I want to display the value of one of the returned field in a text box.  What is the correct syntax?  I tried
RolledFromDisplay.Text = ChangeInfoRecord("RolledFrom")
but that isn't it.

View 1 Replies View Related

Retriving Data From 2 Views By The Value In A Textbox

Aug 9, 2007

i have a textbox which a user enters a numeric value 
i want it to use SqlDataSource and check if the value exists in any of the tables. 
in my text box the users would enter starting from '100000'  or '200000'
i want it to check the view that starts the # with '100000' and 2ed view starts '200000' 
With this i can check in one of the tables and make the selection.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:imacstestConnectionString %>"
SelectCommand="SELECT [ReportNumber] FROM [AppraisalSummaryBlue] WHERE ([ReportNumber] = @ReportNumber)">
<SelectParameters>
<asp:ControlParameter ControlID="txtReport" Name="ReportNumber" PropertyName="Text"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
 
How can i make this possible ?
i was thinking putting a second sqldatasource and have that check the second view but how can i make the textbox goto the correct selectcommand ?

View 1 Replies View Related

How To Retrieve Data From Sqldatasource To Textbox

Sep 4, 2007

 my problem is i can't retrieve data from my sqldatasource to be displayed in textbox... i try to do it in vb codes. somebody help me here?

View 4 Replies View Related

How To Fill Textbox With Data Using Sqldatasource?

Jan 30, 2008

I want to fill text box using sqldatasource ...
how can i do that ??
thanx in advace ..

View 10 Replies View Related

Textbox Inserts Data Into Database

Apr 13, 2008

I have a VERY simple program, it contains a datagrid, textbox and button
 I want it so when I insert something into the textbox and press the button it puts it into the database that is connected to the datagrid and displays it
 I have the following code and I cannot get it to work:
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
 Protected Sub Button1_Click1(ByVal sender As Object, ByVal e As System.EventArgs)
SqlDataSource1.InsertParameters.Add("@Name", TextBox1.Text)
End Sub
 </script>
<html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">
<title>Untitled Page</title></head>
<body><form id="Form1" action="Default.aspx" runat="server">
<table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>"DeleteCommand="DELETE FROM [Table] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [Table] ([Name]) VALUES (@Name)"
ProviderName="<%$ ConnectionStrings:DatabaseConnectionString1.ProviderName %>"SelectCommand="SELECT [ID], [Name] FROM [Table]"
UpdateCommand="UPDATE [Table] SET [Name] = @Name WHERE [ID] = @ID">
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td align="center">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />
</td></tr>
</table></form>
</body>
</html>

View 2 Replies View Related

How To Retrieve Data From Sql Then Put It Into A Label Or Textbox

Apr 22, 2004

i wanna know is there a way to retrieve data from the sql database and then
instead of putting it in the datagrid, can i put a specific field of data to a textbox?

i mean just a data (for example, a username where the password match the username) in a textbox.

thanks

sherlyn

View 1 Replies View Related

Can I Save Textbox Data To BLOB Column?

Oct 21, 2005

Hi experts,
  I have a textbox and a upload file function in my asp.net page.User can either copy/paste their resume in text or upload their resume file and submit the application.The uploaded file will be saved into a BLOB column, but do you know if text in textbox can be saved into BLOB column? 
I received error message on the code:'save Applicant resume to a BLOB-image datatype column objComd.Parameters.Add(New SqlParameter("@AppResume", SqlDbType.NText))
error:Exception has been thrown by the target of an invocation.Operand type clash:ntext is incompatible with image

View 1 Replies View Related

Computing And Assigning A Value To A Textbox From Other Data Regions

May 18, 2007

I am new to SSRS, so perhaps its a trivial question. I was wondering that since all controls have names in the report, is it possible to programatically access values of different textboxes, do some computation and then assign to another text box? I know how to do it using the Aggregate functions and operators, but am not sure if I can access values from textboxes within two different tables and assign the computed value to a third text box on the page (not belonging to any table or other control).



somethig like.... txtTotal.Value = FormatCurrency(txtSalesTotal.Value) - txtDiscount.Value));



Any ideas??



DNG.

View 6 Replies View Related

DB Engine :: Saving Data From One Textbox To 2 Tables?

Oct 1, 2015

i need to display variables from one textbox to 2 or more tables in database, how do i do that?

View 2 Replies View Related

SQL Select Statement (Textbox Used To Grab Data From Database)

Sep 21, 2007

I have a problem....SOMEONE PLEASE HELP!


Here is the setup.
Text Box: User enters in customer transaction number
Button: User clicks button to display information about the customer

Now the database has a lot of unique customer numbers. What I am trying to do is take what the user enters so it can search the database and pull out that customers information. I am having a hard time getting that information from the textbox. Any suggestions! Here is what I have so far.



Private Sub btnViewFlow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnViewFlow.Click

Try



Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection

Me.SqlDataAdapter1 = New System.Data.SqlClient.SqlDataAdapter

Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand

Me.DataSet11 = New links.DataSet1

CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).BeginInit()

'

'SqlConnection1

'

Me.SqlConnection1.ConnectionString = "workstation id=<14852>;packet size=4096;user id=<userID>;password=<Strong Password>;data source=ZRTPD0WB;p" & _

"ersist security info=False;initial catalog=DTR"

'

'SqlDataAdapter1

'

Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1

Me.SqlDataAdapter1.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "DTR_Document_Summary", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("DocumentId", "DocumentId"), New System.Data.Common.DataColumnMapping("PartnerId", "PartnerId"), New System.Data.Common.DataColumnMapping("PartnerName", "PartnerName"), New System.Data.Common.DataColumnMapping("Direction", "Direction"), New System.Data.Common.DataColumnMapping("TranSet", "TranSet")})})

'

'SqlSelectCommand1

'

Me.SqlSelectCommand1.CommandText = "SELECT DocumentId, PartnerId, PartnerName, Direction, TranSet FROM DTR_Document_S" & _

"ummary "

'WHERE (DTR_Document_Summary.PartnerId = 'txtPartnerId.text.toString')"
'THE STATEMENT ABOVE DOESNT WORK

Me.SqlSelectCommand1.Connection = Me.SqlConnection1

'

'DataSet11

'

Me.DataSet11.DataSetName = "DataSet1"

Me.DataSet11.Locale = New System.Globalization.CultureInfo("en-US")

CType(Me.DataSet11, System.ComponentModel.ISupportInitialize).EndInit()



'Open the connection

SqlConnection1.Open()

TextBox1.Text = "Connection Open"




'Populate DataSet11

SqlDataAdapter1.Fill(DataSet11)

TextBox1.Text = "DataSet11 has been filled!"


'Display Data

DataGrid1.DataBind()

TextBox1.Text = "Here is your requested information"



Catch ex As Exception

TextBox1.Text = ex.Message


End Try
'Close the connection

SqlConnection1.Close()


End Sub

View 6 Replies View Related

How Can I Retrieve Data From A SQL Database Writing SQL Characters ( * , ? , [] ) In A Textbox Within My Form?

Nov 12, 2007



let's say I have a table named "myTable" in a SQL database:





UniqueID
FirstName
FamilyName

1
Elizabeth
Moore

2
Chris
Lee

2
Robert
McDonald's



I want to create a SQL query should contain a parameter for example:
SELECT * FROM myTable WHERE UniqueID = @TextBox OR FirstName = @TextBox OR FamilyName = @TextBox,


and when I type in my TextBox the ' * ' character, it should retrieve the whole table...

hope anybody understood, will be happy to explain more.

View 4 Replies View Related

Reporting Services :: Change Visibility Of Textbox (Tablix) Based On Data From Two Datasets?

Jun 11, 2010

I have two charts which are based on their own separate datasets.  One chart shows data aggregated by MONTH, the other chart shows data aggregated by WEEK.  I have put both of these charts inside a rectangle and set their visibility based on whether or not there is data returned by their respective datasets.  This part is working just fine.

However, I have added a tablix to the report, deleted all columns and rows leaving only one remaining row/column so it looks like a textbox.  This tablix is sitting on top of the two charts.  The problem i'm having is that when both charts return no data and they do not show up in the report, the tablix still remains visible. I need to set the visibility but based on a condition between the two different datasets behind each chart.

Here's what I need:  If ONE of the charts returns data, then I need the tablix to be visible.  If neither chart returns data, then I need the tablix to be invisible.  I'm trying to write an IIF statement comparing the two datasets but I get inscope errors.  Isn't it possible to compare values which are contained in two separate datasets in SSRS?

Seems like something like the following logic should work:

IIF(CountRows("Monthly_DataSet") > 0 OR CountRows("Weekly_DataSet") > 0 , FALSE, TRUE)

Obviously the above expression will return syntax errors, but you'll get the point as to how i'm thinking. How can I set the visibility of the tablix based on these two charts?

View 4 Replies View Related

Inserting Data Into Two Tables (Getting ID From Table 1 And Inserting Into Table 2)

Oct 10, 2007

I am trying to insert data into two different tables. I will insert into Table 2 based on an id I get from the Select Statement from Table1.
 Insert Table1(Title,Description,Link,Whatever)Values(@title,@description,@link,@Whatever)Select WhateverID from Table1 Where Description = @DescriptionInsert into Table2(CategoryID,WhateverID)Values(@CategoryID,@WhateverID)
 This statement is not working. What should I do? Should I use a stored procedure?? I am writing in C#. Can someone please help!!

View 3 Replies View Related

SQL Server 2012 :: Get Empty Data Set For Inserting Data?

Nov 11, 2014

I have 2 tables in my database.

one is Race table and 2nd one is Age Range.

I want to write a query where I can see all races and age range as column.

TblRace

ID, RaceName

TblAgeRange

ID,AgeRange.

There is no connection between this two table. I need to display result like below.

Race 17-20 21-30 31-40

A

B

I

W

How do i get this kind of empty data set so that I can fill it out in front end or any better solution. The age range will be displayed as many row as they have. It's not static. Above is just an example.

View 1 Replies View Related

Reference Textbox In Other Textbox

Sep 12, 2007

Hi!
I dont know if i will explain this correctly, but my problem is with reporting service.
I'm supposed to Sum value in one textbox and than that sum use it in sum in other textbox.

Something like this:
Sum(Fields!Abc.Value/(Fields!dfg.Value+Sum(Fields!abc.Value)),"matrix1_RowGroup1")*100
I get error msg 'The Value expression for the textbox 'textbox49' contains an aggregate function (or RunningValue or RowNumber functions) in the argument to another aggregate function (or RunningValue). Aggregate functions cannot be nested inside other aggregate functions.'

Something like this wont work either Sum(Fields!abc.Value/ReportItems("textbox56").Value)*100
Error The Value expression for the textbox 'textbox55' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers.

So, pls help if you know how to reference textbox in other in body of report.
Thx.

View 1 Replies View Related

Inserting The Data Into Text Data Type

Jan 22, 2001

Hi everybody,

In our datbase we have a table with text data type.Help me if anybody knows how to insert text data into text data type of sql server.

i am able to modify and retrive but i am not able to insert text. please if u have idea, please give me reply asap.

Thanks,
Giri

View 1 Replies View Related

Adding New Data Fiels And Inserting Data

Sep 17, 2004

I have some website work lined up and it involves some simple modifications to a MS SQL 2000 server. What I'll need to do is add some new data fields and insert some data.

I have some experience with databases - MS Access and MySQL, but I have never used or seen MS SQL 2000. My question is, is this a relatively simple thing to do for someone who hasn't used it before? I can do these things quite simply in Access or MySQL, so is MS SQL 2000 going to be any different?

Also, does anyone know of any free tutorials online that would help me out?

Thanks

View 1 Replies View Related

Inserting Data To Text File From Database And Inserting Data Back To Database From Text File

Aug 7, 2007

Hello friends....
I am looking for 2 things(using c#.net or vb.net and sql svr 2000)
1.convert data from sql server 2000 database (say customers table from northwinds database) to a text file(separated by commas or just plain space)
2.Insert the data from text file back to database.
Can someone pls give me the detailed code to achieve this....really need this on urgent basis.......Thank You.

View 10 Replies View Related

Help On Inserting Data To DB

Sep 11, 2006

Hi,I m using Microsoft Visual Studio 2005 and SQL server 2000. I have 2 textboxes and a button, what i wanna do is, when i hit the button, the values in textboxes should be inserted into DB. Would you please help me? Thanks in advance.

View 1 Replies View Related

Inserting Data Into DB

May 5, 2007

Hi friends,I have one text box on my form.i need to insert the data from tat text box to DB without clicking on any button.Now i have written the code under text changed event of that text box.So it is inserting whenever i click on that form.Besides this i need to insert data when i close tat window.But it is not inserting when i close tat window.Plse help me.Thanks in advance
With RegardsLijo Rajan

View 1 Replies View Related

Inserting Data

Jun 6, 2007

I have created a form with several fields etc and validation.

After pressing the submit button i have a

if Page.IsValid then .....etc
But in this then bit I want to do a

INSERT the form details to the db.

I have done inserts etc via gridView etc but I just need a form that lets someone enter info and submit etc, so do not now where to or how to place this code to connect then insert etc

thanks

View 3 Replies View Related

Inserting Data To SQL

Dec 6, 2005

Hi all,
 
I'm having a problem saving the information from my web form into my sql database when I clicked on the 'Submit' button.
This is the error message
 Server Error in '/Helpdesk' Application.




ExecuteNonQuery: Connection property has not been initialized.
I've attached my code below. Please advise me on what is wrong... How should I initialise the ExecuteNonQuery.
========= start code ====================
Dim MySQL As String
MySQL = ""
Dim MyConn As SqlConnection = New SqlConnection()
Dim MyCmd As SqlCommand = New SqlCommand()
MyConn.ConnectionString = "Server=ESAWEB2;Database=Helpdesk;Trusted_Connection=True;"
MySQL = "INSERT INTO TBL_TROUBLE_TICKET (Priority) values (' ddlpriority ')"

MyConn.Open()

MyCmd.ExecuteNonQuery()
MsgBox("Record Inserted")
=======end code ===============

View 1 Replies View Related

Need Help Inserting Data!!

Mar 27, 2006

I am not looking for free code but this is driving me out of my mind. I'm a pretty proficient PHP programmer and have been dealing with a form that I was made to program in ASP.Net due to my employer's preferences. I can't attach the code for the form so I have cut and pasted it below. I am needing to know whow do I code this so that the data will go into a MS SQL 2005 database? I already have some coding in it but I don't know if it's correct and any help in getting this fixed would be great as it is slowly driving me up the wall. Thanks!
 
  <%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim conebackups As SqlConnection
Dim strInsert As String
Dim cmdInsert As SqlCommand

conebackups = New SqlConnection("Server=localhost;UID=sa;pwd=kitten33;database=ebackups")
strInsert = "INSERT cust_info ( cust_name, cust_contact, cust_phone, cust_analyst, install_date, cust_username, cust_password, account_request_type, quickbooks_check, peachtree_check, mssba_check, goldmine_check, act_check, mail_info, db_info, mapped_info, mobile_data, mail_option, db_option, mapped_option, mobile_option, backupexec_option ) Values ( 'cust_name, 'cust_contact', 'cust_phone', 'cust_analyst', 'install_date', 'cust_username', 'cust_password', 'account_request_type', 'quickbooks_check', 'peachtree_check', 'mssba_check', 'goldmine_check', 'act_check', 'mail_info', 'db_info', 'mapped_info', 'mobile_data', 'mail_option', 'db_option', 'mapped_option', 'mobile_option', 'backupexec_option' )"
cmdInsert = New SqlCommand(strInsert, conebackups)
conebackups.Open()
cmdInsert.ExecuteNonQuery()
conebackups.Close()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Weston Backup Questionnaire</title>
<script language="javascript" type="text/javascript">
</script>
</head>
<body>
<form id="westonquest" runat="server">
<div>
<div style="border-left-color: black; border-bottom-color: black; border-top-color: black;
text-align: center; border-right-color: black" title="Weston Backup Questionnaire">
<table>
<tr>
<td colspan="3" style="width: 540px; height: 30px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">Weston Online Backup Questionnaire</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 10px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Please fill out the following information
as accurately as possible. Any incorrect information may affect the customers online
backup in a serious manner. All of the following fields require an answer before
you can submit the form.<br />
</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px">
<br />
<span style="font-size: 14pt; font-family: Verdana">Customer and Analyst Information</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Customer Name:<br />
</span>
<asp:DropDownList ID="cust_name" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="232px" DataSourceID="SqlDataSource1" DataTextField="cust_name" DataValueField="cust_name">
<asp:ListItem>Select Customer Name.....</asp:ListItem>
<asp:ListItem Value="WestonANC">Weston - ANC</asp:ListItem>
<asp:ListItem Value="WestonBND">Weston - BND</asp:ListItem>
</asp:DropDownList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ebackupsConnectionString %>"
SelectCommand="SELECT [cust_name] FROM [backup_info]"></asp:SqlDataSource>
<span style="font-size: 8pt; font-family: Verdana">
<br />
<br />
Customer Contact:                  
                  Customer Phone Number:<br />
<asp:TextBox ID="cust_contact" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="190px"></asp:TextBox>
              <asp:TextBox ID="cust_phone"
runat="server" Font-Names="Verdana" Font-Size="X-Small" Width="146px"></asp:TextBox><br />
<br />
Analyst:                      
                       
      Today's Date: (mm/dd/yyy format)<br />
<asp:DropDownList ID="cust_analyst" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="162px">
<asp:ListItem>Select Analyst.....</asp:ListItem>
<asp:ListItem>Brock McFarlane</asp:ListItem>
<asp:ListItem>Cameron Farrally</asp:ListItem>
<asp:ListItem>Eric Spinney</asp:ListItem>
<asp:ListItem>Greg Freeman</asp:ListItem>
<asp:ListItem>Kevin Mark</asp:ListItem>
<asp:ListItem>Mark Anderson</asp:ListItem>
<asp:ListItem>Mike Murphy</asp:ListItem>
<asp:ListItem>Tim Elder</asp:ListItem>
</asp:DropDownList>
                      
<asp:TextBox ID="install_date" runat="server" Font-Names="Verdana" Font-Size="X-Small"></asp:TextBox><br />
<br />
Customer E-Backup Username:                
  Customer E-Backup Password:<br />
<asp:TextBox ID="cust_username" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="150px"></asp:TextBox>
                         <asp:TextBox ID="cust_password" runat="server" Font-Names="Verdana" Font-Size="X-Small"
Width="150px" TextMode="Password"></asp:TextBox><br />
<br />
<asp:RadioButtonList ID="account_request_type" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="430px">
<asp:ListItem Value="New">New Account</asp:ListItem>
<asp:ListItem Value="Change">Account Change</asp:ListItem>
<asp:ListItem Value="Delete">Account Deletion</asp:ListItem>
</asp:RadioButtonList></span><br />
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center;">
<span style="font-size: 14pt; font-family: Verdana">Financial / CRM Programs</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer use any of the
following financial / CRM products?<br />
<br />
Quickbooks<asp:CheckBox ID="quickbooks_check" runat="server" />
         Peachtree Accounting<asp:CheckBox ID="peachtree_check"
runat="server" />
         MS Small Business Acct<asp:CheckBox ID="mssba_check"
runat="server" />
        
<br />
Sage Goldmine<asp:CheckBox ID="goldmine_check" runat="server" />
         Sage ACT!<asp:CheckBox ID="act_check" runat="server" /><br />
<br />
<br />
</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">BackupExec / NTBackup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer use BackupExec,
NTBackup or any other backup software? </span><span style="color: #ff0066"><span
style="font-size: 8pt; font-family: Verdana">(Important!)<br />
<br />
</span>
<asp:RadioButtonList ID="backupexec_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
ForeColor="Black" RepeatDirection="Horizontal" Width="127px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList></span><span style="font-size: 8pt; font-family: Verdana">If "Yes"
which program do they use for backups?  <asp:TextBox ID="backup_program" runat="server"
Font-Names="Verdana" Font-Size="X-Small" Width="200px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 14pt; font-family: Verdana">Mail Server Backup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer want to backup
their E-Mail system?<br />
<br />
</span>
<asp:RadioButtonList ID="mail_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="127px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" what
e-mail server software does the customer use?
<asp:TextBox ID="mail_info" runat="server" Font-Italic="False" Font-Names="Verdana"
Font-Overline="False" Font-Size="X-Small" Width="171px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Database Backup</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 30px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer have a SQL, Access
or other RDMS that they wish to have backed up?<br />
<br />
</span>
<asp:RadioButtonList ID="db_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="128px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" please
list the databases the customers needs to have backed up.<br />
<asp:TextBox ID="db_info" runat="server" Height="102px" Width="321px"></asp:TextBox><br />
<br />
<br />
</span>
</td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Network Drives</span></td>
</tr>
<tr>
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt"><span style="font-family: Verdana">Does the customer want
any shared or mapped drives backed up? </span><span style="color: #ff0066"><span
style="font-family: Verdana">(Important!)</span><span style="color: #000000"><span
style="font-family: Verdana">
<br />
<br />
</span>
<asp:RadioButtonList ID="mapped_option" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="126px">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:RadioButtonList></span></span></span><span style="font-size: 8pt; font-family: Verdana">If
"Yes" please list the mapped or network drive the customer wishes to backup.<br />
<asp:TextBox ID="mapped_info" runat="server" Height="101px" Width="321px"></asp:TextBox><br />
<br />
</span>
</td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<span style="font-size: 16pt; font-family: Verdana">Mobile Users</span></td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: left">
<hr />
<span style="font-size: 8pt; font-family: Verdana">Does the customer have mobile users
that they wish to have data backed up for?<br />
<br />
</span>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Names="Verdana" Font-Size="X-Small"
RepeatDirection="Horizontal" Width="121px">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList><span style="font-size: 8pt; font-family: Verdana">If "Yes" please
enter the username and machine name for mobile user as well as when they will be
in the office for remote install of software.<br />
<asp:TextBox ID="TextBox1" runat="server" Height="101px" Width="321px"></asp:TextBox><br />
<br />
</span>
</td>
</tr>
<tr style="color: #000000">
<td colspan="3" style="width: 540px; height: 21px; text-align: center">
<asp:Button ID="Button" runat="server" Text="Submit Form For Processing" /></td>
</tr>
</table>
</div>

</div>
</form>
</body>
</html> 

View 5 Replies View Related

Inserting Data PK/FK

Feb 18, 2006

I'm trying to insert a record into a master table, but b/c of the foreign key relationship, I know that I need to first insert a record into the child table so I don't get a foreign key error. The problem is that the record that I'm inserting doesn't have any columns that match up (similar)to the child table, and only a few that match up to the master table.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved