主题:数据库连接不上,请大家帮忙看看. 越快越好.
我用的是visual studio 2005 数据库是sql server 2000标准版.
我写了一个注册页,通过注册把用户的信息提交到数据库里面,
我不知道是什么地方出的错.总是提示连接错误
注册代码
<TABLE WIDTH=770 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<form id="form1" runat="server">
<TR align="center" >
<TD COLSPAN=3 class="css" valign="top" style="width: 781px; height: 38px">
</TD>
</TR>
<TR>
<td colspan="3" rowspan="2" style="width: 781px">
<table border="1" align="center" cellspacing="0" class="css" style="width: 770px; height: 491px" bordercolor="#adbdce" bordercolordark="#d4d6e0" bordercolorlight="#000099">
<tr align="center">
<td height="40" colspan="2" style="background-color: #d4d6e0">
会员注册</td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Username"
ErrorMessage="用户名不能为空">*</asp:RequiredFieldValidator>用户名:</td>
<td style="width: 336px" > <asp:TextBox ID="Username" runat="server" MaxLength="20" Width="150px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="Username"
ErrorMessage="用户名已经存在" OnServerValidate="CustomValidator1_ServerValidate">用户名已经存在</asp:CustomValidator><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Userpwd"
ErrorMessage="密码不能为空">*</asp:RequiredFieldValidator>
密码:</td>
<td style="height: 28px; width: 336px;"> <asp:TextBox ID="Userpwd" runat="server" MaxLength="20" TextMode="Password"
Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="Userpwd"
ControlToValidate="Userpwd1" Display="Dynamic" ErrorMessage="两次输入密码不一致">*</asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Userpwd1"
Display="Dynamic" ErrorMessage="确认密码不能为空">*</asp:RequiredFieldValidator>
确认密码:</td>
<td style="height: 28px; width: 336px;"> <asp:TextBox ID="Userpwd1" runat="server" MaxLength="20" TextMode="Password"
Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="CompanyName"
ErrorMessage="公司名称不能为空">*</asp:RequiredFieldValidator> 公司名称:</td>
<td rowspan="" style="height: 29px; width: 336px;"> <asp:TextBox ID="CompanyName" runat="server" MaxLength="50" Width="253px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
用户类型:</td>
<td style="height: 28px; width: 336px;"> <asp:DropDownList ID="UserType" runat="server">
<asp:ListItem>货主</asp:ListItem>
<asp:ListItem>车主</asp:ListItem>
<asp:ListItem>物流企业</asp:ListItem>
</asp:DropDownList><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="Linkman"
ErrorMessage="联系人不能为空">*</asp:RequiredFieldValidator>联系人:</td>
<td style="width: 336px"> <asp:TextBox ID="Linkman" runat="server" Width="80px"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Tel"
ErrorMessage="联系电话格式填写错误" ValidationExpression="(\d{3}-\d{8})|(\d{4}-\d{7})">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="Tel"
Display="Dynamic" ErrorMessage="联系电话不能为空">*</asp:RequiredFieldValidator>联系电话:</td>
<td colspan="" style="width: 336px"> <asp:TextBox ID="Tel" runat="server" Width="150px"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="MobileTelephone"
Display="Dynamic" ErrorMessage="手机号码格式填写错误" ValidationExpression="\d{11}">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="MobileTelephone"
Display="Dynamic" ErrorMessage="手机号码不能为空">*</asp:RequiredFieldValidator>
手机:</td>
<td style="height: 25px; width: 336px;"> <asp:TextBox ID="MobileTelephone" runat="server"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" Display="Dynamic"
ErrorMessage="Email格式填写错误" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="Email">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="Email不能为空">*</asp:RequiredFieldValidator>Email:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Email" runat="server"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="Address"
ErrorMessage="联系地址不能为空">*</asp:RequiredFieldValidator>联系地址:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Address" runat="server" Width="250px"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="Postalcode"
ErrorMessage="邮政编码格式填写错误" ValidationExpression="\d{6}">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="Postalcode"
Display="Dynamic" ErrorMessage="邮政编码不能为空">*</asp:RequiredFieldValidator>邮政编码:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Postalcode" runat="server"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="Problem"
Display="Dynamic" ErrorMessage="提示问题不能为空">*</asp:RequiredFieldValidator>提示问题:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Problem" runat="server"></asp:TextBox>
(取回密码时使用,请牢记)</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="Answer"
Display="Dynamic" ErrorMessage="答案不能为空">*</asp:RequiredFieldValidator>问题答案:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Answer" runat="server"></asp:TextBox>
(取回密码时使用,请牢记)</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">备注:</td>
<td style="height: 89px; width: 336px;"> <asp:TextBox ID="Bewrite" runat="server" Height="69px" TextMode="MultiLine"
Width="315px" >无</asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="center" style="background-color: #d4d6e0"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text=" 注册 " />
<input id="Button2" type="reset" value=" 重置 " />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" />
<br />
</td>
</tr>
</table>
</td>
</TR>
<TR>
</TR>
<TR>
<TD COLSPAN=3 style="height: 45px; width: 781px;">
</TD>
</TR>
</form>
</TABLE>
我写了一个注册页,通过注册把用户的信息提交到数据库里面,
我不知道是什么地方出的错.总是提示连接错误
注册代码
<TABLE WIDTH=770 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
<form id="form1" runat="server">
<TR align="center" >
<TD COLSPAN=3 class="css" valign="top" style="width: 781px; height: 38px">
</TD>
</TR>
<TR>
<td colspan="3" rowspan="2" style="width: 781px">
<table border="1" align="center" cellspacing="0" class="css" style="width: 770px; height: 491px" bordercolor="#adbdce" bordercolordark="#d4d6e0" bordercolorlight="#000099">
<tr align="center">
<td height="40" colspan="2" style="background-color: #d4d6e0">
会员注册</td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Username"
ErrorMessage="用户名不能为空">*</asp:RequiredFieldValidator>用户名:</td>
<td style="width: 336px" > <asp:TextBox ID="Username" runat="server" MaxLength="20" Width="150px"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ControlToValidate="Username"
ErrorMessage="用户名已经存在" OnServerValidate="CustomValidator1_ServerValidate">用户名已经存在</asp:CustomValidator><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Userpwd"
ErrorMessage="密码不能为空">*</asp:RequiredFieldValidator>
密码:</td>
<td style="height: 28px; width: 336px;"> <asp:TextBox ID="Userpwd" runat="server" MaxLength="20" TextMode="Password"
Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="Userpwd"
ControlToValidate="Userpwd1" Display="Dynamic" ErrorMessage="两次输入密码不一致">*</asp:CompareValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Userpwd1"
Display="Dynamic" ErrorMessage="确认密码不能为空">*</asp:RequiredFieldValidator>
确认密码:</td>
<td style="height: 28px; width: 336px;"> <asp:TextBox ID="Userpwd1" runat="server" MaxLength="20" TextMode="Password"
Width="150px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="CompanyName"
ErrorMessage="公司名称不能为空">*</asp:RequiredFieldValidator> 公司名称:</td>
<td rowspan="" style="height: 29px; width: 336px;"> <asp:TextBox ID="CompanyName" runat="server" MaxLength="50" Width="253px"></asp:TextBox></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
用户类型:</td>
<td style="height: 28px; width: 336px;"> <asp:DropDownList ID="UserType" runat="server">
<asp:ListItem>货主</asp:ListItem>
<asp:ListItem>车主</asp:ListItem>
<asp:ListItem>物流企业</asp:ListItem>
</asp:DropDownList><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="Linkman"
ErrorMessage="联系人不能为空">*</asp:RequiredFieldValidator>联系人:</td>
<td style="width: 336px"> <asp:TextBox ID="Linkman" runat="server" Width="80px"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Tel"
ErrorMessage="联系电话格式填写错误" ValidationExpression="(\d{3}-\d{8})|(\d{4}-\d{7})">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="Tel"
Display="Dynamic" ErrorMessage="联系电话不能为空">*</asp:RequiredFieldValidator>联系电话:</td>
<td colspan="" style="width: 336px"> <asp:TextBox ID="Tel" runat="server" Width="150px"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="MobileTelephone"
Display="Dynamic" ErrorMessage="手机号码格式填写错误" ValidationExpression="\d{11}">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="MobileTelephone"
Display="Dynamic" ErrorMessage="手机号码不能为空">*</asp:RequiredFieldValidator>
手机:</td>
<td style="height: 25px; width: 336px;"> <asp:TextBox ID="MobileTelephone" runat="server"></asp:TextBox><span style="height: 29px; color: #ff0066;"></span></td>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" Display="Dynamic"
ErrorMessage="Email格式填写错误" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="Email">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="Email不能为空">*</asp:RequiredFieldValidator>Email:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Email" runat="server"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="Address"
ErrorMessage="联系地址不能为空">*</asp:RequiredFieldValidator>联系地址:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Address" runat="server" Width="250px"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="Postalcode"
ErrorMessage="邮政编码格式填写错误" ValidationExpression="\d{6}">*</asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ControlToValidate="Postalcode"
Display="Dynamic" ErrorMessage="邮政编码不能为空">*</asp:RequiredFieldValidator>邮政编码:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Postalcode" runat="server"></asp:TextBox>
</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="Problem"
Display="Dynamic" ErrorMessage="提示问题不能为空">*</asp:RequiredFieldValidator>提示问题:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Problem" runat="server"></asp:TextBox>
(取回密码时使用,请牢记)</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">
<asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="Answer"
Display="Dynamic" ErrorMessage="答案不能为空">*</asp:RequiredFieldValidator>问题答案:</td>
<td style="height: 32px; width: 336px;"> <asp:TextBox ID="Answer" runat="server"></asp:TextBox>
(取回密码时使用,请牢记)</tr>
<tr>
<td align="right" style="width: 115px; height: 28px; background-color: #d4d6e0;">备注:</td>
<td style="height: 89px; width: 336px;"> <asp:TextBox ID="Bewrite" runat="server" Height="69px" TextMode="MultiLine"
Width="315px" >无</asp:TextBox></td>
</tr>
<tr>
<td colspan="2" align="center" style="background-color: #d4d6e0"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text=" 注册 " />
<input id="Button2" type="reset" value=" 重置 " />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" />
<br />
</td>
</tr>
</table>
</td>
</TR>
<TR>
</TR>
<TR>
<TD COLSPAN=3 style="height: 45px; width: 781px;">
</TD>
</TR>
</form>
</TABLE>