can't get SQLDataSource to work....

wings9697

Member
Joined
Aug 27, 2007
Messages
23
Location
Washington, DC
Programming Experience
10+
Hi, all.. I new to VB.Net. I am using SQL Server 2005 (not Express) and .Net to build a case documentation log.

When I try to connect the database to my .NET solution explorer data resources folder, I get this error "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL : http://go.microsoft.com/fwlink/?LlinkId=49251" Visual Studio installed SQL Server Express 2005 but it telling me it wouldn't create remote connections and the crap out, even though I was using an instance I had on my local PC. So I gave up, deinstalled Express and installed Developer, and things were fine up to now.

I built my database and tables and followed the instructions in the wizard to build the SqlDataSource contol. I built the connection string, configured the Select Statement, checked both Advanced SQL generation options, and finished the wizard. I then added "SqlDataSource1.Insert()" to the event handler for the first web page, believing that according to the book, that with the SQL statements already generated, all I had to do was send the Insert trigger and my data would be added to the table. The only thing that happened was a row being added with an increment in the record number.

When I tried to fix that problem, I came accross an entry in this forumn that said I had to actually add the database to the App_Data folder in the Solution Explorer. So I attemped to add a "new item" and got the above error. I've scoured the forums trying to find a solutuion. Can anyone point me in the right direction?

Here's my code :

<%@ Page Language="VB" Debug="true"%>
<%@ Import Namespace="System.Data" %>

<!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 TextBox18_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("~/Main Menu.aspx")
End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox20.Text = TextBox3.Text
SqlDataSource1.Insert()
End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>CSES Case Log Work Form</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:panel ID="Panel1" runat="server" BackColor="Blue" ForeColor="Blue" Height="47px"
Width="681px">
<asp:Label ID="Label19" runat="server" Font-Bold="True" Font-Size="X-Large" ForeColor="White"
Height="30px" Text="CSES Case Log Form" Width="413px"></asp:Label>
</asp:panel>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mclu_caselogConnectionString %>"
SelectCommand="SELECT * FROM [caselog]" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [caselog] WHERE [case_number] = @original_case_number AND [case_cses_num] = @original_case_cses_num AND [case_agentnum] = @original_case_agentnum AND [case_ccn] = @original_case_ccn AND [case_location] = @original_case_location AND [case_complname] = @original_case_complname AND [case_compfname] = @original_case_compfname AND [case_district] = @original_case_district AND [case_psa] = @original_case_psa AND [case_leadtechlname] = @original_case_leadtechlname AND [case_leadtechfname] = @original_case_leadtechfname AND [case_asstechlname] = @original_case_asstechlname AND [case_asstechfname] = @original_case_asstechfname AND [case_leaddetlname] = @original_case_leaddetlname AND [case_leaddetfname] = @original_case_leaddetfname AND [case_evtdate] = @original_case_evtdate AND [case_rptdate] = @original_case_rptdate AND [case_off_inc] = @original_case_off_inc AND [case_photo] = @original_case_photo AND [case_evidence] = @original_case_evidence AND [case_prints] = @original_case_prints AND [case_diagram] = @original_case_diagram AND [case_section] = @original_case_section AND [case_notes] = @original_case_notes" InsertCommand="INSERT INTO [caselog] ([case_cses_num], [case_agentnum], [case_ccn], [case_location], [case_complname], [case_compfname], [case_district], [case_psa], [case_leadtechlname], [case_leadtechfname], [case_asstechlname], [case_asstechfname], [case_leaddetlname], [case_leaddetfname], [case_evtdate], [case_rptdate], [case_off_inc], [case_photo], [case_evidence], [case_prints], [case_diagram], [case_section], [case_notes]) VALUES (@case_cses_num, @case_agentnum, @case_ccn, @case_location, @case_complname, @case_compfname, @case_district, @case_psa, @case_leadtechlname, @case_leadtechfname, @case_asstechlname, @case_asstechfname, @case_leaddetlname, @case_leaddetfname, @case_evtdate, @case_rptdate, @case_off_inc, @case_photo, @case_evidence, @case_prints, @case_diagram, @case_section, @case_notes)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [caselog] SET [case_cses_num] = @case_cses_num, [case_agentnum] = @case_agentnum, [case_ccn] = @case_ccn, [case_location] = @case_location, [case_complname] = @case_complname, [case_compfname] = @case_compfname, [case_district] = @case_district, [case_psa] = @case_psa, [case_leadtechlname] = @case_leadtechlname, [case_leadtechfname] = @case_leadtechfname, [case_asstechlname] = @case_asstechlname, [case_asstechfname] = @case_asstechfname, [case_leaddetlname] = @case_leaddetlname, [case_leaddetfname] = @case_leaddetfname, [case_evtdate] = @case_evtdate, [case_rptdate] = @case_rptdate, [case_off_inc] = @case_off_inc, [case_photo] = @case_photo, [case_evidence] = @case_evidence, [case_prints] = @case_prints, [case_diagram] = @case_diagram, [case_section] = @case_section, [case_notes] = @case_notes WHERE [case_number] = @original_case_number AND [case_cses_num] = @original_case_cses_num AND [case_agentnum] = @original_case_agentnum AND [case_ccn] = @original_case_ccn AND [case_location] = @original_case_location AND [case_complname] = @original_case_complname AND [case_compfname] = @original_case_compfname AND [case_district] = @original_case_district AND [case_psa] = @original_case_psa AND [case_leadtechlname] = @original_case_leadtechlname AND [case_leadtechfname] = @original_case_leadtechfname AND [case_asstechlname] = @original_case_asstechlname AND [case_asstechfname] = @original_case_asstechfname AND [case_leaddetlname] = @original_case_leaddetlname AND [case_leaddetfname] = @original_case_leaddetfname AND [case_evtdate] = @original_case_evtdate AND [case_rptdate] = @original_case_rptdate AND [case_off_inc] = @original_case_off_inc AND [case_photo] = @original_case_photo AND [case_evidence] = @original_case_evidence AND [case_prints] = @original_case_prints AND [case_diagram] = @original_case_diagram AND [case_section] = @original_case_section AND [case_notes] = @original_case_notes">
<DeleteParameters>
<asp:parameter Name="original_case_number" Type="Int32" />
<asp:parameter Name="original_case_cses_num" Type="String" />
<asp:parameter Name="original_case_agentnum" Type="String" />
<asp:parameter Name="original_case_ccn" Type="String" />
<asp:parameter Name="original_case_location" Type="String" />
<asp:parameter Name="original_case_complname" Type="String" />
<asp:parameter Name="original_case_compfname" Type="String" />
<asp:parameter Name="original_case_district" Type="String" />
<asp:parameter Name="original_case_psa" Type="String" />
<asp:parameter Name="original_case_leadtechlname" Type="String" />
<asp:parameter Name="original_case_leadtechfname" Type="String" />
<asp:parameter Name="original_case_asstechlname" Type="String" />
<asp:parameter Name="original_case_asstechfname" Type="String" />
<asp:parameter Name="original_case_leaddetlname" Type="String" />
<asp:parameter Name="original_case_leaddetfname" Type="String" />
<asp:parameter Name="original_case_evtdate" Type="DateTime" />
<asp:parameter Name="original_case_rptdate" Type="DateTime" />
<asp:parameter Name="original_case_off_inc" Type="String" />
<asp:parameter Name="original_case_photo" Type="Boolean" />
<asp:parameter Name="original_case_evidence" Type="Boolean" />
<asp:parameter Name="original_case_prints" Type="Boolean" />
<asp:parameter Name="original_case_diagram" Type="Boolean" />
<asp:parameter Name="original_case_section" Type="String" />
<asp:parameter Name="original_case_notes" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="case_cses_num" Type="String" />
<asp:parameter Name="case_agentnum" Type="String" />
<asp:parameter Name="case_ccn" Type="String" />
<asp:parameter Name="case_location" Type="String" />
<asp:parameter Name="case_complname" Type="String" />
<asp:parameter Name="case_compfname" Type="String" />
<asp:parameter Name="case_district" Type="String" />
<asp:parameter Name="case_psa" Type="String" />
<asp:parameter Name="case_leadtechlname" Type="String" />
<asp:parameter Name="case_leadtechfname" Type="String" />
<asp:parameter Name="case_asstechlname" Type="String" />
<asp:parameter Name="case_asstechfname" Type="String" />
<asp:parameter Name="case_leaddetlname" Type="String" />
<asp:parameter Name="case_leaddetfname" Type="String" />
<asp:parameter Name="case_evtdate" Type="DateTime" />
<asp:parameter Name="case_rptdate" Type="DateTime" />
<asp:parameter Name="case_off_inc" Type="String" />
<asp:parameter Name="case_photo" Type="Boolean" />
<asp:parameter Name="case_evidence" Type="Boolean" />
<asp:parameter Name="case_prints" Type="Boolean" />
<asp:parameter Name="case_diagram" Type="Boolean" />
<asp:parameter Name="case_section" Type="String" />
<asp:parameter Name="case_notes" Type="String" />
<asp:parameter Name="original_case_number" Type="Int32" />
<asp:parameter Name="original_case_cses_num" Type="String" />
<asp:parameter Name="original_case_agentnum" Type="String" />
<asp:parameter Name="original_case_ccn" Type="String" />
<asp:parameter Name="original_case_location" Type="String" />
<asp:parameter Name="original_case_complname" Type="String" />
<asp:parameter Name="original_case_compfname" Type="String" />
<asp:parameter Name="original_case_district" Type="String" />
<asp:parameter Name="original_case_psa" Type="String" />
<asp:parameter Name="original_case_leadtechlname" Type="String" />
<asp:parameter Name="original_case_leadtechfname" Type="String" />
<asp:parameter Name="original_case_asstechlname" Type="String" />
<asp:parameter Name="original_case_asstechfname" Type="String" />
<asp:parameter Name="original_case_leaddetlname" Type="String" />
<asp:parameter Name="original_case_leaddetfname" Type="String" />
<asp:parameter Name="original_case_evtdate" Type="DateTime" />
<asp:parameter Name="original_case_rptdate" Type="DateTime" />
<asp:parameter Name="original_case_off_inc" Type="String" />
<asp:parameter Name="original_case_photo" Type="Boolean" />
<asp:parameter Name="original_case_evidence" Type="Boolean" />
<asp:parameter Name="original_case_prints" Type="Boolean" />
<asp:parameter Name="original_case_diagram" Type="Boolean" />
<asp:parameter Name="original_case_section" Type="String" />
<asp:parameter Name="original_case_notes" Type="String" />
</UpdateParameters>

<InsertParameters>
<asp:parameter Name="case_cses_num" Type="String" />
<asp:parameter Name="case_agentnum" Type="String" />
<asp:parameter Name="case_ccn" Type="String" />
<asp:parameter Name="case_location" Type="String" />
<asp:parameter Name="case_complname" Type="String" />
<asp:parameter Name="case_compfname" Type="String" />
<asp:parameter Name="case_district" Type="String" />
<asp:parameter Name="case_psa" Type="String" />
<asp:parameter Name="case_leadtechlname" Type="String" />
<asp:parameter Name="case_leadtechfname" Type="String" />
<asp:parameter Name="case_asstechlname" Type="String" />
<asp:parameter Name="case_asstechfname" Type="String" />
<asp:parameter Name="case_leaddetlname" Type="String" />
<asp:parameter Name="case_leaddetfname" Type="String" />
<asp:parameter Name="case_evtdate" Type="DateTime" />
<asp:parameter Name="case_rptdate" Type="DateTime" />
<asp:parameter Name="case_off_inc" Type="String" />
<asp:parameter Name="case_photo" Type="Boolean" />
<asp:parameter Name="case_evidence" Type="Boolean" />
<asp:parameter Name="case_prints" Type="Boolean" />
<asp:parameter Name="case_diagram" Type="Boolean" />
<asp:parameter Name="case_section" Type="String" />
<asp:parameter Name="case_notes" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
                       
           
                       
               
                      
        
<table style="width: 668px">
<tr>
<td style="width: 100px">
<asp:Label ID="Label6" runat="server" Font-Size="Small" Text="Current Date" Width="83px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label20" runat="server" Font-Size="Small" Text="Event Date" Width="75px"></asp:Label></td>
<td style="width: 100px">
 <asp:Label ID="Label1" runat="server" Font-Size="Small" Text="CSES Number"
Width="82px"></asp:Label></td>
<td style="width: 240px">
<asp:Label ID="Label3" runat="server" Font-Size="Small" Text="CCN" Width="69px"></asp:Label></td>
<td style="width: 471px">
<asp:Label ID="Label2" runat="server" Font-Size="Small" Text="MCLU User ID"></asp:Label></td>
</tr>
<tr>
<td style="width: 100px; height: 24px;">
<asp:TextBox ID="TextBox6" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_rptdate") %>' /></td>
<td style="width: 100px; height: 24px;">
<asp:TextBox ID="TextBox19" runat="server" Height="11px" Width="90px" Text='<%# Bind("case_evtdate") %>' /></td>
<td style="height: 24px;">
<asp:TextBox ID="TextBox1" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_cses_num") %>' /></td>
<td style="width: 240px; height: 24px">
<asp:TextBox ID="TextBox3" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_ccn") %>' /></td>
<td style="width: 471px; height: 24px;">
<asp:TextBox ID="TextBox2" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_agentnum") %>' /></td>
</tr>
<tr>
<td style="width: 100px">
 
</td>
<td style="width: 100px">
</td>
<td>
</td>
<td style="width: 240px">
</td>
<td style="width: 471px">
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label4" runat="server" Font-Size="Small" Text="District" Width="66px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label5" runat="server" Font-Size="Small" Text="PSA" Width="91px"></asp:Label></td>
<td>
<asp:Label ID="Label7" runat="server" Font-Size="Small" Text="Location" Width="94px"></asp:Label></td>
<td style="width: 240px">
</td>
<td style="width: 471px">
<asp:Label ID="Label8" runat="server" Font-Size="Small" Text="Offense/Incident" Width="123px"></asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox4" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_district") %>' /></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox5" runat="server" Height="11px" Width="89px" Text='<%# Bind("case_psa") %>' /></td>
<td>
<asp:TextBox ID="TextBox7" runat="server" Height="11px" Width="190px" Text='<%# Bind("case_location") %>' /></td>
<td style="width: 240px">
</td>
<td style="width: 471px">
<asp:TextBox ID="TextBox8" runat="server" Height="11px" Width="150px" Text='<%# Bind("case_off_inc") %>' /></td>
</tr>
</table>
</div>
<br />
<table>
<tr>
<td style="width: 100px">
<asp:Label ID="Label9" runat="server" Font-Size="Small" Text="Complainant Last Name"
Width="153px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label10" runat="server" Font-Size="Small" Text="Complainant First Name"
Width="153px"></asp:Label></td>
<td style="width: 23px">
</td>
<td style="width: 100px">
<asp:Label ID="Label13" runat="server" Font-Size="Small" Text="Lead Technician Last Name"
Width="153px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label14" runat="server" Font-Size="Small" Text="Lead Technician First Name"
Width="153px"></asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox9" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_complname") %>' /></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox10" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_compfname") %>' /></td>
<td style="width: 23px">
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox11" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_leadtechlname") %>' /></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox12" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_leadtechfname") %>' /></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 23px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label11" runat="server" Font-Size="Small" Text="Lead Detecive Last Name"
Width="153px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label12" runat="server" Font-Size="Small" Text="Lead Detecive First Name"
Width="153px"></asp:Label></td>
<td style="width: 23px">
</td>
<td style="width: 100px">
<asp:Label ID="Label15" runat="server" Font-Size="Small" Text="Asst Technician Last Name"
Width="153px"></asp:Label></td>
<td style="width: 100px">
<asp:Label ID="Label16" runat="server" Font-Size="Small" Text="Asst Technician First Name"
Width="153px"></asp:Label></td>
</tr>
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox13" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_leaddetlname") %>' /></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox14" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_leaddetfname") %>' /></td>
<td style="width: 23px">
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox15" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_asstechlname") %>' /></td>
<td style="width: 100px">
<asp:TextBox ID="TextBox16" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_asstechfname") %>' /></td>
</tr>
<tr>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 23px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label17" runat="server" Font-Size="Small" Text="Section" Width="153px"></asp:Label></td>
<td style="width: 100px">
</td>
<td style="width: 23px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:TextBox ID="TextBox17" runat="server" Height="11px" Width="145px" Text='<%# Bind("case_asstechlname") %>' /></td>
<td style="width: 100px">
</td>
<td style="width: 23px">
</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox20" runat="server"></asp:TextBox></td>
<td style="width: 100px">
</td>
</tr>
</table>
<br />
<table style="width: 642px; height: 48px">
<tr>
<td style="width: 100px">
<asp:Label ID="Label21" runat="server" Font-Size="Small" Text="Results"></asp:Label></td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 100px">
<asp:Label ID="Label22" runat="server" Font-Size="Small" Text="Photos"></asp:Label>
<asp:CheckBox ID="CheckBox1" runat="server" Text='<%# Bind("case_photo") %>' /></ td>
<td style="width: 100px">
<asp:Label ID="Label23" runat="server" Font-Size="Small" Text="Evidence"></asp:Label>
<asp:CheckBox ID="CheckBox2" runat="server" Text='<%# Bind("case_evidence") %>' /></ td>
<td style="width: 100px">
<asp:Label ID="Label24" runat="server" Font-Size="Small" Text="Prints"></asp:Label>
<asp:CheckBox ID="CheckBox3" runat="server" Text='<%# Bind("case_prints") %>' /></ td>
<td style="width: 100px">
<asp:Label ID="Label25" runat="server" Font-Size="Small" Text="Diagram"></asp:Label>
<asp:CheckBox ID="CheckBox4" runat="server" Text='<%# Bind("case_diagram") %>' /></ td>
</tr>
</table>
<br />
<br />
<asp:Label ID="Label18" runat="server" Font-Size="Small" Text="Case Notes" Width="123px"></asp:Label><br />
<asp:TextBox ID="TextBox18" runat="server" Height="55px" OnTextChanged="TextBox18_TextChanged"
Width="632px" Text='<%# Bind("case_notes") %>' /><br />
<br />
<table>
<tr>
<td style="width: 216px">
</td>
<td style="width: 392px">
                  
<asp:Button ID="Button3" runat="server" Text="Submit Report" OnClick="Button3_Click" />
  
<asp:Button ID="Button4" runat="server" Text="Exit Without Submit" OnClick="Button4_Click" /></td>
</tr>
</table>
 <br />
<br />
                       
                       
                       
                       
             
</form>
</body>
</html>
 
Back
Top