hello... Probably a simple question but I have to ask...using visual basic 2005 express...
I have two tables one with last name and basic info, one with detailed info. Both set up with Primary key and Foreign key.
I have a combo box that displays the last names and then by clicking the last name, text boxes fill with the "other" data from table1, however, there are some text boxes that I would like to fill with data from the table2. Any pointers??
I’m trying to teach myself C# and trying to create a simple (so I thought) little database using Infragistic's UltraWebGrid (Althought my question is more ASPish). Every sample I run across seems to only show the very basics and doesn’t seem to go into anything more than just a simple table and displaying it in a Gird. Which is pretty easy and I can do that all day and night. Anyway, my database has three tables in a one-to-many relationship. The database is of Trucking companies and which states they service and they can service multiple states. The database is like this: Compnies: TruckerID, Company Name, Address, etc. ServiceStates: TruckerID, StateID StateNames: StateID, StateName, StateAbbreviation I would like to show the States that they service in a Hierarchical Grid. I can write the SQL to do what I want to, basically do an inner join on ServicesStates and StateNames based on the TruckerID. I can sit all day and night getting what I would like to display in the WebGrid in the query builder on the SQL server. I figured it wouldn’t be much of a stretch to be able to do that in UltraWebGrid (Or whatever floats your boat). Anyway, on to my question. :) While browsing the samples on everything, I've figured out, that I will need to use the SqlDataAdapter Class, to access the database. Then I'll need to use the SQLConnection Class, and populate a DataSet. Now while in VS I can go to WebSite -> Add New Item -> DataSet slap my tables on there and away I go (at least it seems that way). If I do that, what exactly is the difference between doing that and using the dataset class? When I do that, is that not creating the dataset? I see all the classes it created (I named mine Trucking). I see all the SQL statements in the classes. I imagine I must be missing something *REALLY* simple or this just went way over my head at by at least 40,000 ft. Thanks, marly
Hai,i'm new asp.net and vb.net i have few textboxes and few dropdownlists.i want to insert data in (.mdf )database with these textboxes and dropdown lists please anybody can tell me a sample and simple example.
Hi, I have a page created within VS 2005 which uses a detailsView with a SQLDataSource which has insert, edit and delete items allowed with it. The problem is that if I delete a record I dont want to refresh the page as I want to set a label value to say item deleted. The problem then though is to select the item to delete I have a drop down which populates the details view on index change, but if I delete the item I cannot do a databind when its complete because it just binds to the existing dataset and does not do a fresh call on the database.Is there a command I can run to refresh the dataset on click of the delete button?Thanks
Hi,i have a question, i have a VS2005 and a SQL server 2000 enterprise in my office that i used for web developement,iam new to this, i made a data driven site using some automated controls available in the toolbox, but i need to made some manual process, like i need to make a LABEL show the SUM of specific number fields from my data base, they say i have to make a OLEDB connection using VB, but i don't know how,can you tell me how?Thanks
Hey all, I had a few questions about how to properly use the sqldatasource - I have a form with a single dropdownlist, databound to an sqldatasource that just has a select statement. Over the course of time, the client has requested additional dropdownlists, all of which point to different sqldatasources. After I reached 4 or 5, I noticed the page started to load incredibly slower. I played around with the caching features, and after a good while of reading up on it, finally was able to cache the page /data and notice an increase. Later, another 4 dropdownlists were added, 3 of which all take the same data. I assumed if I had 3 dropdownlists, which need the same data, I should use the same sqldatasource. What do you think? My page is behaving unaccepteably slow again. As a test, I created a new page, and bound it in the same fashion. I slowly added more dropdownlists /sqldatasources, and found it lags a bit on the initial load time (maybe 10-12 seconds of processing time before the page loads). The tables it is pulling data from do not have a primary key, and i'm doing select statements that return roughly 100-200 rows of data (per dropdownlist on average). I'm only selecting 1 column name (no select * here) I'm just curious if anyone has experienced similar issues, and also if there is anything I should do as a best practice while working with the sqldatasource. I've used hundreds of these on forms, and never experienced a problem. I only started noticing this on pages that have multiple. Also, when using multiple dropdowns that need the same data (I know that sounds goofy - why have 3 dropdownlists with the same data) should I use 3 individual datasources? Thanks for your help in advance, Mike
Hello, I would like to databind a textbox (the Text property) and I have try the following syntax: Text='<%# Bind("au_fname") %>' but there's no Datasource property for this control. I have defined a SqlDatasource object but can I link it to my Textbox. I have looked at the properties of the control: there's a Expressions section in which I can configure a connection string but thar's all. When I run the page I have no error but the textbox field is empty. Thanks for your help.
Does anybody know a good way to get a (near) live view of a sqlce database that doesn't involve ResultSets? I tried to use a resultset with the Sensitive option set, but it doesn't like the joins that I have to do in order to have the data make sense to the user.
If I add a new row and try to move there using the code below, nothing happens (neither movement to a new position nor error message), unless I remove the radio button bindings. (The same thing occurs if I attempt to move to any record that has a null value in the database field for a radio button).
myLastRow = dsData.Tables["Results"].NewRow();
dsData.Tables["Results"].Rows.Add(myLastRow);
I attempt to move by changing the value of the position property of the BindingContext object.
How can I retain the radio button bindings and still be able to add and move to a new row?
Here's a new one I came across that stumped me for a bit. DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'xxxx'. It appears that one of my dropdown menus was referencing the old SqlDataSource1for its data source id. I had already changed the name of the of the id to something else though. To fix it, I just updated the reference to the new name.
I m trying to UPDATE database using FormView and SqlDataSource and here is my code: <asp:SqlDataSource ID="sqlDS1" runat="server" ConnectionString="<%$ ConnectionStrings:myDB %>"UpdateCommand="UPDATE [Consultants] SET [firstName]=@FIRSTNAME,[lastName]=@LASTNAME,[skillCategoryID]=@SKILLCATID,[resourceManagerID]=@RMID,[AMgroupID]=@AMGROUPID,[SkillSet]=@SKILLSET,[statusID]=@STATUSID,[location]=@LOCATION,[comments]=@COMMENTS,[profile]=@PROFILE,[isAvailable]=@ISAVAILABLE,[dateModified]=getdate(),[focusID]=1 WHERE ([id]=@ID)"> <UpdateParameters> <asp:FormParameter FormField="txtFName" Name="FIRSTNAME" /> <asp:FormParameter FormField="txtLName" Name="LASTNAME" /> <asp:FormParameter FormField="ddlSkillCat" Name="SKILLCATID" /> <asp:FormParameter FormField="ddlRM" Name="RMID" /> <asp:FormParameter FormField="ddlAMGroup" Name="AMGROUPID" /> <asp:FormParameter FormField="txtSkillset" Name="SKILLSET" /> <asp:FormParameter FormField="ddlStatus" Name="STATUSID" Type="Int16" /> <asp:FormParameter FormField="txtLocation" Name="LOCATION" /> <asp:FormParameter FormField="txtComments" Name="COMMENTS"/> <asp:FormParameter FormField="txtProfile" Name="PROFILE" /> <asp:FormParameter FormField="cbAvailable" Name="ISAVAILABLE" /> <asp:QueryStringParameter Type="Int32" Name="ID" QueryStringField="id" /> </UpdateParameters>
</asp:SqlDataSource> //******************************************************************* <asp:FormView DefaultMode="Edit" ID="FormView1" runat="server" DataSourceID="sqlDS1" DataKeyNames="id"> <EditItemTemplate> <tr> <td class="blacktextbold"> Resource Manager: </td> <td class="blacktext"> <asp:DropDownList ID="ddlRM" CssClass="blacktext" runat="server" DataSource="<%#GetRM()%>" DataTextField="RMName" DataValueField="userID" SelectedValue="<%#Bind('RMID')%>" AppendDataBoundItems="true"> <asp:ListItem Value="-1">--Select RM--</asp:ListItem> </asp:DropDownList> <asp:CustomValidator ID="cvRM" runat="server" ValidationGroup="gpInsert" ControlToValidate="ddlRM" ClientValidationFunction="validateDropdown" OnServerValidate="servervalidateDropdown" Display="Dynamic" ErrorMessage="Required Field" CssClass="redtextsmallbold" /> </td> </tr> //******************************************************** here is my GetRM() function: protected DataSet GetRM() { string strConnection = ConfigurationManager.ConnectionStrings["myDB"].ToString(); SqlConnection objConnection = new SqlConnection(strConnection); String sqlSkillCats = "SELECT Roles.roleID, Roles.roleName, UsersInRoles.userID, UsersInRoles.roleID AS Expr1, Users.firstName + ' ' + Users.lastName AS RMName, Users.id AS Expr2" + " FROM Users INNER JOIN" + " UsersInRoles ON Users.id = UsersInRoles.userID CROSS JOIN" + " Roles" + " WHERE (Roles.roleName = 'accountmanager') AND (UsersInRoles.roleID = Roles.roleID) ORDER BY Users.firstName"; SqlDataAdapter objAdapter = new SqlDataAdapter(sqlSkillCats, objConnection); objConnection.Open(); //ddlDataSet = new DataSet(); try { objAdapter.Fill(dsConsultantRM, "ConsultantRM"); } catch (Exception ex) { Response.Write(ex.Message); } objConnection.Close(); return dsConsultantRM; }//****************************************************************** i get this error when i load the page:DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'RMID'. basically i m trying to UPDATE database using the value selected in the DropDownList, can anyone tell me whats wrong here...PLZ HELP!
HAI guys,i am suneel.i have a problem..please help me..i am binding my datalist.i have set my dtakey field to the primary key of teh database.i am not displaying the primary key(file_id).but i am displaying the other fields in that table.i have set databinder.Eval(container,dataitem."file_name").i have put one delete button in the item template...if i want to build now...i am getting an error.....DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'file_ID'.wat i have to do..please get me the reply..
Hi,Seems like a lot of people are having a similiar problem that I am having right now, but I am not able to find the solution to it. On the Page_load event, the gridview does display the data from database. When I click a button to insert the same data but different Waste_Profile_Num value, it gives me the databinding error. Component_Profile_ID is declared as an Identity and it is the primary key to the table. Anyway help???Ok, the following are code that I have: 1 <asp:SqlDataSource ID="sqlDSMaterialComposition" runat="server" ConnectionString="<%$ ConnectionStrings:HAZConnectionString %>" 2 SelectCommand="SELECT dbo.Component_Profile.Component_Profile_ID AS Component_Profile_ID, dbo.Component.Component, dbo.Component_Profile.Concentration, dbo.Component_Profile.Range, dbo.Component_Profile.Waste_Profile_Num, dbo.Component.Component_ID FROM dbo.Component INNER JOIN dbo.Component_Profile ON dbo.Component.Component_ID = dbo.Component_Profile.Component_ID WHERE (dbo.Component_Profile.Waste_Profile_Num = @Waste_Profile_Num)"> 3 <SelectParameters> 4 <asp:SessionParameter Name="Waste_Profile_Num" SessionField="Waste_Profile_Num" Type="Int32" /> 5 </SelectParameters> 6 </asp:SqlDataSource> 7 8 9 <asp:GridView ID="GridViewMaterialComposition" 10 runat="server" 11 DataKeyNames="Component_Profile_ID,Component_ID" 12 AutoGenerateColumns="False" ShowFooter="true"> 13 <Columns> 14 <asp:BoundField DataField="Component" HeaderText="Component" SortExpression="Component" FooterText="Total"/> 15 <asp:TemplateField HeaderText="Concentration" FooterStyle-Font-Bold="true"> 16 <ItemTemplate> 17 <%# SumConcentration(decimal.Parse(Eval("Concentration").ToString())).tostring("N2") %> 18 </ItemTemplate> 19 <FooterTemplate> 20 <%# GetConcentration().tostring("N2") %> 21 </FooterTemplate> 22 </asp:TemplateField> 23 <asp:BoundField DataField="Range" HeaderText="Range" SortExpression="Range" /> 24 <asp:BoundField DataField="Component_Profile_ID" HeaderText="Component_Profile_ID" ReadOnly="True" SortExpression="Component_Profile_ID" Visible="true" /> 25 <asp:BoundField DataField="Component_ID" HeaderText="Component_ID" ReadOnly="True" SortExpression="Component_ID" Visible="true"/> 26 <asp:BoundField DataField="Waste_Profile_Num" HeaderText="Waste_Profile_Num" ReadOnly="true" SortExpression="Waste_Profile_Num" Visible="true" /> 27 <asp:CommandField ShowEditButton="true" /> 28 <asp:TemplateField Visible="false"> 29 <ItemTemplate> 30 <asp:Label ID="lblComponentProfileID" runat="Server" Text='<% # Eval("Component_Profile_ID") %>'></asp:Label> 31 <asp:Label ID="lblComponentID" runat="Server" Text='<% # Eval("Component_ID") %>'></asp:Label> 32 </ItemTemplate> 33 </asp:TemplateField> 34 </Columns> 35 </asp:GridView>The following are the code-behind: 1 sqlSelect = "SELECT Range, Concentration, Component_ID FROM Component_Profile WHERE (Component_Profile.Waste_Profile_Num = " & previousWasteProfileNum & ")" 2 sqlDSMaterialComposition.SelectCommand = sqlSelect 3 Try 4 Dim dvComposition As Data.DataView = CType(sqlDSMaterialComposition.Select(DataSourceSelectArguments.Empty), Data.DataView) 5 For Each dr As Data.DataRow In dvComposition.Table.Rows 6 insertSql = "INSERT INTO Component_Profile ([Range], [Concentration], [Component_ID], [Waste_Profile_Num]) " 7 insertSql &= "VALUES (" & dr("Range").ToString.Trim & ", " & dr("Concentration").ToString.Trim & ", " & dr("Component_ID").ToString.Trim & ", " & CInt(Session("Waste_Profile_Num").ToString()) & ")" 8 sqlDSMaterialComposition.InsertCommand = insertSql 9 sqlDSMaterialComposition.Insert() 10 Next 11 Catch ex As Exception 12 13 End Try
I am actually a newbie to asp.net and i m using ASP.net 3.5 i.e, VWD 2008. i am using it for the first time as my tool to develop a website for my final year project. i am planning to develop an online job recruitment site like www.monster.com. Rigth now i am confused how will i manage my database. i've learned to use databinding concept of SQL SERVER in VWD 2008 but will it be enough to handle such huge # of Job postings and employers and as well as Resumes in pdf of word format? or do i have to create a separate databse in SQL Server and to connect it with my website? i am confused at the moment. please help me in this matter. Regards, Jigzy
Hey. I need to substitute a value from a table if the input var is null. This is fine if the value coming from table is not null. But, it the table value is also null, it doesn't work. The problem I'm getting is in the isnull line which is in Dark green color because @inFileVersion is set to null explicitly and when the isnull function evaluates, value returned from DR.FileVersion is also null which is correct. I want the null=null to return true which is why i set ansi_nulls off. But it doesn't return anything. And the select statement should return something but in my case it returns null. If I comment the isnull statements in the where clause, everything works fine. Please tell me what am I doing wrong. Is it possible to do this without setting the ansi_nulls to off??? Thank you
set ansi_nulls off
go
declare
@inFileName VARCHAR (100),
@inFileSize INT,
@Id int,
@inlanguageid INT,
@inFileVersion VARCHAR (100),
@ExeState int
set @inFileName = 'A0006337.EXE'
set @inFileSize = 28796
set @Id= 1
set @inlanguageid =null
set @inFileVersion =NULL
set @ExeState =0
select Dr.StateID from table1 dR
where
DR.[FileName] = @inFileName
AND DR.FileSize =@inFileSize
AND DR.FileVersion = isnull(@inFileVersion,DR.FileVersion)
In my report i have CNAME parameter , which allows null value. I checked Allow null value check box in report parameter properties.
when i preview the report , it displays checked NULL check box beside CNAME parameter . I want to give some meaningful name(i.e.ALLCustomers) to this checkbox instead of NULL.
In the flat file SampleID and Product are populated in the first row only, rest of the rows only have values for Rep_Number, Protein, Fat, Solids.
SampleID and Product are blank for the rest of the rows. So my task is to fill those blank rows with the first row that has the sampleID and Product and load into the table.
I have a report that is run on a monthly basis with a default date of null. The stored procedure determines the month-end date that it should use should it be sent a null date.
The report works fine when I tell it to create a history entry; however, when I try to add a subscription it doesn't appear to like the null parameter value. Since I have told the report to have a default value of null it doesn't allow me to enter a value on the subscription page.
Now, I suppose I could remove the parameter altogether from the stored proc, but then the users would never be able to run the report for a previous time period. Can someone explain to me why default values aren't allowed to be used on subscriptions when they seem to work fine for ad hoc and scheduled reports? This is really quite frustrating as most of my reports require a date value and default to null so that the user doesn't have to enter them for the latest data.
An internal error occurred on the report server. See the error log for more details. (rsInternalError) Get Online Help
I run a stored procedure for which I have a return variable. The stored procedure returns the ID of a row in a table if it exists:
m_sqlCmd.ExecuteScalar();
The m_sqlCmd has been fed an SQLParameter with direction set to output. When the stored proc returns, I want to test it. Now when there IS a row it returns the ID ok. When the row doesn't exist, in my watch I have:
m_sqlParam.SqlValue with value {Null}
I can't seem to work out how to test this value out. I've tried several things but none seem to work.
This line compiles ok, but the following runs into the IF statement as if the SqlValue is null??
if (m_sqlParam.SqlValue != null).... {
// I'm here!! I thought the watch says this is null??? }
Sorry if this is obvious, but I can't work this one out!!
Looks like there was a fix and then I read this fix is not a fix. Does anyone know how this can be rectified? Does it mean that only Windows authentiation is the only way it works. The Software is over 2 years old, there are no excuses.
I am getting this error: "Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails." -- But my value is not null. I did a response.write on it and it show the value. Of course, it would be nice if I could do a breakpoint but that doesn't seem to be working. I'll attach a couple of images below of my code, the error, and the breakpoint error.
Server Error in '/' Application.
Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'OrderID', table 'outman.outman.Contact'; column does not allow nulls. INSERT fails.Source Error:
Line 89: sContact.Phone = sPhone.Text.Trim Line 90: sContact.Email = sEmail.Text.Trim Line 91: sContact.Save() Line 92: Line 93: Dim bContact As Contact = New Contact()Source File: F:InetpubwwwrootOutman KnifeCheckout.aspx.vb Line: 91 Stack Trace:
hi,my structure table in database:Amount float(53) not null default 0when i try to run his script:alter table ABC alter column Amount float(53) nullit can only set the Amount to allow null, but can't set the defaultvalue to empty.anyone know how to set the field to allow null and default set toempty, no value.thanks
I've built a sample CLR function with the following declaration....
CREATE FUNCTION GetManager(@DeptCode nvarchar(3)) RETURNS nvarchar(1000) WITH RETURNS NULL ON NULL INPUT AS EXTERNAL NAME Assembly1.[ClassLibrary1.MyVBClass].MyManager
It returns the value "Unknown" as it would have for any unknown DeptCode, as-programmed.
I'm of the theory it should have returned NULL without actually firing the function? Or is this only for non-CLR items... or stored procedures, not functions?
We have a case where in we should show date based on conditions for e.g if we had a column defined as
col varchar(10) then we would show col as 'NULL' for some condition and actual value when no condition
Normaly date values are stored here e.g under col 20150901 .
Case when col>'20150901' then 'NULL' else col end as Derivedcol
Note this is an extract process and we are presenting data by pumping the data in a table .
Now there is another similar column -colz varchar(10) which stores date but doesnt have case condition so whenever date has no value its shows null which is database null.
So whats the difference between database null and string null ?
How can we show database null for the case condition instead of string "null"?
I have two columns A (which allows nulls) and B( which does not allow nulls). How can I add the contents of columns A and B SO THAT I DO NOT GET A NULL RESULT WHEN A IS NULL.
The result of A+B concatanation will be stored in a column, C.
I've got a query on a particular table returning an odd result:
SELECT DISTINCT WorkStation FROM Invoice WHERE WorkStation Is Not Null ORDER BY WorkStation
This query returns the rows I'd expect plus a null row. This doesn't happen in databases at other sites, or in other tables at this site. The following query behaves as I'd expect returning only non-null AccountNumbers.
SELECT DISTINCT AccountNumber FROM Suppliers WHERE AccountNumber Is Not Null ORDER BY AccountNumber
I can't reproduce these results on another site on a table of the same structure, or on another table at this site.
Any suggestions as to what might be going on?
Pertinent info: --- select @@Version
Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1) --- dbcc checkdb Abridged result: CHECKDB found 0 allocation errors and 0 consistency errors in database 'POS'. --- SELECT * INTO #Inv FROM Invoice
SELECT DISTINCT WorkStation FROM #Inv WHERE WorkStation Is Not Null ORDER BY WorkStation
Does not reproduce this problem (and so is a probable fix) but the questions remains, what causes this?
I have 595 default constraints in my database. I can return a list of them using the following:
select * from sys.default_constraints
Is there a way I can return a list of just the ones where NULL is still allowed? I want to update all of the columns with a default value to not allow NULLs.