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


ADVERTISEMENT

Retrieve Data From Database And Display It In A Label

Jan 21, 2008

Below is code for inserting data into the database that I know works, so I thought if I replace  "Insert" with "Select" I could retrieve a specific row from my database and present it in a label or text box but nothing happened. How can I retrieve a row or rows from a database using vb code and display it in a textbox? I'm using visual web developer 2008 which is similar to 2005.
Thank you.
 
 Dim UserDatasource As New SqlDataSourceUserDatasource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
 
UserDatasource.InsertCommandType = SqlDataSourceCommandType.Text
UserDatasource.InsertCommand = "insert into table1 (Username, comments, points,totalpoints, ipaddress, datatimestamp) values (@Username, @comments, @points,@totalpoints, @ipaddress, @datatimestamp)"
 
 UserDatasource.InsertParameters.Add("username", Context.User.Identity.Name)
UserDatasource.InsertParameters.Add("comments", txtSearch.Text)UserDatasource.InsertParameters.Add("points", points)
UserDatasource.InsertParameters.Add("ipaddress", Request.UserHostAddress)UserDatasource.InsertParameters.Add("datatimestamp", DateTime.Now())
 Dim rowaffected As Integer = 0
 
Try
rowaffected = UserDatasource.Insert()MsgBox("Thanks for the post", MsgBoxStyle.OkOnly, "Post Executed")
txtSearch.Text = ""Catch ex As Exception
MsgBox("Please sign in or sign up to post comment", MsgBoxStyle.OkOnly, "Login Error")
End Try
 

View 2 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

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 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

Binding A SqlDataSource To A TextBox Or Label

Feb 28, 2007

I have a SQL database with 1 column in it.. it is a do not call registry for my office.  I want to make a web application so our leads can go on the web and request to be put on the do not call list.  problem is, if their number already exists, it gets a violation of primary key... Normal handling for this would be to do a select query based on user input, and if it exists in the database, tell them that, else do the insert query... Problem is, i cant seem to figure out how to bind the result of the select query to a textbox or label so i can compare the results to do that logic.  Any ideas?  This is in asp .net 2.0.  Thanks! -Dan       

View 5 Replies View Related

Trying To Retrieve Info From Db- Not Sure How To Label This Question

Sep 7, 2004

I have a table that has a column with multiple manufacturer names. Many rows are identical manufacturers. I want to create an asp page that shows only one instance of a particular manufacturer.

Basically if I have 30 entries of Manufacturer 1, 40 entries of Manufacturer 2, etc. I only want to see Manufacturer 1 and Manufacturer 2 once in the display, not as many times as it is listed in the column. Is this an ASP or SQL question?

Basically I know the beginning should look like this:

Code:


SELECT Col1, Col2
FROM dbo.tbl_Myinfo
ORDER BY Col2


But that is about the extent of where I know what to do.

I wanted to create this so I can list the manufacturers that I currently have loaded in my SQL table/ available for more detailed searching.

View 2 Replies View Related

SQL Data Not Showing In Label

Mar 13, 2008

Here is my code.  Basically what I am doing is selecting from the database based on the current user.   The ReaderResults.Text label is not showing the info pulled from the database, and the ReaderError.Text label is not showing an error.  I also tried putting the ReaderResults.Text label inside the loop and that didnt work. Any suggestions?
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")Dim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL As String
selectSQL = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd2 As New SqlCommand(selectSQL, con)
Dim reader As SqlDataReaderDim CompanyKey
Try
con.Open()
reader = cmd2.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 1 Replies View Related

SQL Data Not Showing Up In My Label

Mar 13, 2008

The ReaderResults.Text is not returning a value.  I am not sure what is going on because the table and all columns are full, Label1.Text shows the current username of the user loggedon, and no error is showing up in ReaderError.Text.  Anyone have any ideas?
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Database ConnectionDim con As New SqlConnection("Data Source = .SQLExpress;integrated security=true;attachdbfilename=|DataDirectory|ASPNETDB.mdf;user instance=true")
'Job1 InfoDim currentUserID
currentUserID = Context.User.Identity.Name.ToString()
Label1.Text = currentUserID
Dim selectSQL1 As String
selectSQL1 = "SELECT companyKey FROM Company WHERE UserID = ('" + currentUserID + "')"Dim cmd1 As New SqlCommand(selectSQL1, con)
Dim reader As SqlDataReaderDim CompanyKey
'Job1 Select
Try
con.Open()
reader = cmd1.ExecuteReader()Do While reader.Read()
CompanyKey = reader("CompanyKey").ToString()
Loop
reader.Close()Catch err As Exception
ReaderError.Text = "Error selecting record."
ReaderError.Text &= err.Message
ReaderResults.Text = CompanyKey
Finally
con.Close()
End Try

View 3 Replies View Related

Data Range To Be Label In Report

Jul 21, 2014

I have a report based on a query which requires the user to input the date range. I would like this date range to be a label in the report.

I already keying tha formula fo the data range.. Audit Fees

Report is my form

Between [Forms]![Purchase Report]![From] And [Forms]![Purchase Report]![To]

I am trying to run a report for the period "December 1 2010 to March 31 2011" However, it came out a warning message box.

"The expression is typed incorrectly or it is too complex.... try simplifying the expression by assigning parts pf the expression to variables".

View 1 Replies View Related

Problem With Data Group Label

May 14, 2008

Can anyone tell me why the following returns a warning and does not work:




Code Snippet=IIf(InStr(Fields!Unit.Value,"-") > 0, Left(Fields!Unit.Value,InStr(Fields!Unit.Value,"-")-1),Fields!Unit.Value)





but the following does work as expected:




Code Snippet=IIf(InStr(Fields!Unit.Value,"-") > 0, Left(Fields!Unit.Value,3),Fields!Unit.Value)





The warning message that I get is:


[rsRuntimeErrorInExpression] The HeadingLabel expression for the chart €˜chart4€™ contains an error: Argument 'Length' must be greater or equal to zero.



What I am trying to do is only display the text preceding the "-" if it exists within the text otherwise just show the text as it is.

Thanks

View 3 Replies View Related

How To Show Data In A Label Item?

May 21, 2006

SqlCeConnection cn = new SqlCeConnection("Data Source=\Program Files\test\tel.sdf");
try
{
SqlCeCommand cmd = cn.CreateCommand();

cmd.CommandText = "SELECT * from phone where PhoneNo = '0912312345'";

SqlCeDataAdapter adp = new SqlCeDataAdapter(cmd);

DataSet ds = new DataSet();

adp.Fill(ds);
this.dataGrid1.DataSource = ds.Tables[0];

label1.Text =Convert.ToString(????????????);

label2.Text =Convert.ToString(????????????);

}

finally
{
if (cn.State != ConnectionState.Closed)
{
cn.Close();
}
}

I can show the result in the DataGrid1

however, I want the label1 to show the Name,

and label2 to show the phoneNo.

how to do in here,

label1.Text =Convert.ToString(????????????);

label2.Text =Convert.ToString(????????????);

thanks

View 1 Replies View Related

Reporting Services :: Data Label Should Be Centre In Pie Chart

Oct 12, 2015

I have pie chart. In this i have to display the category group name , count as a data label. In this both category name and count should be in seperate line and should be in centre allignment. But for it is not centre allignment. In series label properties i am using this expression,=Fields!Group.Value & VbCrLf & Count(Fields!Countvalue.Value).I am geeting new line. But not in center allignment.

View 2 Replies View Related

Reporting Services :: SSRS Databar - Data Label Formatting

Nov 8, 2015

Data Label formatting issue in SSRS Databar? Refer the below screenshot:

View 3 Replies View Related

Problem Use Sqldatasource To Access Stored Procedure And Get Data Bind To Label Control

Aug 30, 2007

Hi every experts
I have a exist Stored Procedure in SQL 2005 Server, the stored procedure contain few output parameter, I have no problem to get result from output parameter to display using label control by using SqlCommand in Visual Studio 2003. Now new in Visual Studio 2005, I can't use sqlcommand wizard anymore, therefore I try to use the new sqldatasource control. When I Configure Datasource in Sqldatasource wizard, I assign select field using exist stored procedure, the wizard control return all parameter in the list with auto assign the direction type(input/ouput....), after that, whatever I try, I click on Test Query Button at last part, I always get error message The Query did not return any data table.
My Question is How can I setup sqldatasource to access Stored Procedure which contain output parameter, and after that How can I assign the output parameter value to bind to the label control's Text field to show on web?
Thanks anyone, who can give me any advice.
Satoshi

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

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 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 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

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

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

Asp.net Page Is Unable To Retrieve The Right Data Calling The Store Procedure From The Dataset/data Adapter

Apr 11, 2007

I'm trying to figure this out
 I have a store procedure that return the userId if a user exists in my table, return 0 otherwise
------------------------------------------------------------------------
 Create Procedure spUpdatePasswordByUserId
@userName varchar(20),
@password varchar(20)
AS
Begin
Declare @userId int
Select @userId = (Select userId from userInfo Where userName = @userName and password = @password)
if (@userId > 0)
return @userId
else
return 0
------------------------------------------------------------------
I create a function called UpdatePasswordByUserId in my dataset with the above stored procedure that returns a scalar value. When I preview the data from the table adapter in my dataset, it spits out the right value.
But when I call this UpdatepasswordByUserId from an asp.net page, it returns null/blank/0
 passport.UserInfoTableAdapters oUserInfo = new UserInfoTableAdapters();
Response.Write("userId: " + oUserInfo.UpdatePasswordByUserId(txtUserName.text, txtPassword.text) );
 Do you guys have any idea why?
 
 

View 6 Replies View Related

How?retrieve Data From Table1 Then Save The Retrive Data To Table2...

May 8, 2008

Good day., please help me,in a formview control, i set it in Insert Mode, so it should display info from table 1 but when i click on the insert button, it will insert it in table 2.btw, table 1 and table 2 are in the same database?? how about if they are not in the same database?how?please help me,Thanks.,SALAMAT PO., 

View 3 Replies View Related

Retrieve Text File Data In SSE For Data Acquisition System

Oct 24, 2007

Hey All,
I am developing a data acquistion system which monitors the amount of energy that a user consumes in different parts of a house and displays the information in real time on their computer screen. I am collecting the data through tranducers attached to the circuit breakers in the breaker box and sending the data to analog-to-digital converter channels in a MCU. I am retrieving the data from the serial port and storing it to a text file. Each line of data in the text file represents three fields which are separated by commas. I will be reading data from multiple data collection boxes so the first field is the unit number, the second fied represents the analog-to-digital converter channel number from each unit, and the third field is the data that is collected from the ATD channel. I am trying to use SSE to retrieve the data from the text file, and parse each line of data into individual columns in a databse. Then I want to be able to extract the data associated with a particular ATD channel number from the databse and display it in the appropriate text field on a windows form.
I've got the MCU programmed. I have no problem collecting the data from the serial port, and I can do the visual basic programming okay. I have absolutely no clue how to read the data into the database, continuosly read new values into the databse, and then access the stored data to update the text fields on the form. Please help if you can, I've been working on this specific problem for a couple of weeks and I'm not making any progress. Thanks.

View 3 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

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







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