我有3列:
Name
nvarchar 100
FirstName
nvarchar 50
LastName
nvarchar 50
如果Name
都用完了(50个字符),FirstName + ' ' + LastName
可以接受DatagramSocket ds = null;
ds = new DatagramSocket();
ds.setSoTimeout(30000);
InetAddress serverAddr = InetAddress.getByName(IP_ADDRESS);
DatagramPacket dp;
dp = new DatagramPacket(udpMsg.getBytes(), udpMsg.length(), serverAddr, UDP_SERVER_PORT);
ds.send(dp);
byte[] receiveData = new byte[1024];
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
ds.receive(receivePacket);
response = new String(receivePacket.getData(), "UTF-8");
String str = new String(receivePacket.getData(), "UTF-8");
data1 = str.substring(0,receivePacket.getLength());
private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String sender = intent.getStringExtra("sender");
Bundle msg = intent.getBundleExtra("message");
}
};
LocalBroadcastManager.getInstance(context).registerReceiver(
mMessageReceiver, new IntentFilter("UDPBroadcast"));
吗?
答案 0 :(得分:2)
如果两者都用完(50个字符),那么姓名可以接受名字+''+姓氏吗?
否。
如果FirstName和LastName实际上使用了整个50个字符的列宽,则该空间没有空间,并且包含该空间的新字符串将不合适。
OTOH,实际上没有理由先存储然后再存储包含两者的另一列。使用SELECT Firstname + ' ' + LastName as [Name] FROM TableName
实际上,最好不要先存储+空间+后存储,因为一旦获得任何数据块的两个副本,最终一个将是错误的。有人将更改名称,并且“名称”字段将不会更新。